Skip to content

Commit 84684c7

Browse files
Copilotzackees
andcommitted
Address code review: move imports to module level
Agent-Logs-Url: https://github.com/FastLED/fbuild/sessions/565e62a0-9fa2-4594-b7b0-0ef03f2489b9 Co-authored-by: zackees <6856673+zackees@users.noreply.github.com>
1 parent 70ff3d2 commit 84684c7

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

src/fbuild/packages/framework_esp32.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import _thread
5050
import json
51+
import zipfile
5152
from pathlib import Path
5253
from typing import Any, Dict, List, Optional
5354

@@ -257,8 +258,6 @@ def _download_and_extract_to_temp(name: str, url: str, desc: str) -> tuple[str,
257258
if self.show_progress:
258259
print(f"Extracting {desc}...")
259260
if archive_name.endswith(".zip"):
260-
import zipfile
261-
262261
with zipfile.ZipFile(archive_path, "r") as zf:
263262
zf.extractall(temp_dir)
264263
else:

tests/unit/packages/test_framework_archive_formats.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import io
11+
import os
1112
import tarfile
1213
import zipfile
1314
from pathlib import Path
@@ -21,8 +22,6 @@
2122

2223
def _create_tar_xz_archive(archive_path: Path, content_dir_name: str = "framework") -> None:
2324
"""Create a valid .tar.xz archive with a single top-level directory."""
24-
import os
25-
2625
with tarfile.open(archive_path, "w:xz") as tar:
2726
# Create a directory entry
2827
dirinfo = tarfile.TarInfo(name=content_dir_name)
@@ -39,8 +38,6 @@ def _create_tar_xz_archive(archive_path: Path, content_dir_name: str = "framewor
3938

4039
def _create_tar_gz_archive(archive_path: Path, content_dir_name: str = "framework") -> None:
4140
"""Create a valid .tar.gz archive with a single top-level directory."""
42-
import os
43-
4441
with tarfile.open(archive_path, "w:gz") as tar:
4542
dirinfo = tarfile.TarInfo(name=content_dir_name)
4643
dirinfo.type = tarfile.DIRTYPE
@@ -55,8 +52,6 @@ def _create_tar_gz_archive(archive_path: Path, content_dir_name: str = "framewor
5552

5653
def _create_zip_archive(archive_path: Path, content_dir_name: str = "framework") -> None:
5754
"""Create a valid .zip archive with a single top-level directory."""
58-
import os
59-
6055
with zipfile.ZipFile(archive_path, "w") as zf:
6156
zf.writestr(f"{content_dir_name}/package.json", os.urandom(4096).hex())
6257

0 commit comments

Comments
 (0)