Skip to content

Commit b37f117

Browse files
Copilotmnriem
andauthored
Address code review: fix import style and rename local aliases
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/9fb9a8ea-0967-4baf-b95c-7101e423ff58 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
1 parent a434e5a commit b37f117

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,14 +4321,14 @@ def extension_update(
43214321
try:
43224322
# 6. Validate extension ID from archive BEFORE modifying installation
43234323
# Handle both root-level and nested extension.yml (GitHub auto-generated archives)
4324-
from .extensions import _detect_archive_format as _det_fmt_upd
4325-
import tarfile as _tarfile_upd
4326-
archive_fmt_upd = _det_fmt_upd(str(zip_path))
4324+
from .extensions import _detect_archive_format as _ext_det_fmt
4325+
import tarfile as _tarfile
4326+
archive_fmt = _ext_det_fmt(str(zip_path))
43274327
import yaml
43284328
manifest_data = None
43294329

4330-
if archive_fmt_upd == "tar.gz":
4331-
with _tarfile_upd.open(zip_path, "r:gz") as tf:
4330+
if archive_fmt == "tar.gz":
4331+
with _tarfile.open(zip_path, "r:gz") as tf:
43324332
# First try root-level extension.yml
43334333
try:
43344334
m = tf.getmember("extension.yml")
@@ -5009,7 +5009,6 @@ def _validate_and_install_local(yaml_path: Path, source_label: str) -> None:
50095009
from urllib.parse import urlparse
50105010
from urllib.request import urlopen # noqa: S310
50115011
from .extensions import _detect_archive_format as _wf_det_fmt
5012-
import tarfile as _wf_tarfile
50135012

50145013
parsed_src = urlparse(source)
50155014
src_host = parsed_src.hostname or ""

tests/test_extensions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,9 @@ def test_install_from_tar_gz_nested(self, extension_dir, project_dir, temp_dir):
11031103
def test_install_from_tar_gz_no_manifest(self, project_dir, temp_dir):
11041104
"""install_from_zip raises ValidationError when tarball has no extension.yml."""
11051105
import tarfile
1106+
import io
11061107
archive = temp_dir / "bad.tar.gz"
11071108
with tarfile.open(archive, "w:gz") as tf:
1108-
import io
11091109
data = b"no manifest here"
11101110
info = tarfile.TarInfo(name="readme.txt")
11111111
info.size = len(data)
@@ -1117,7 +1117,8 @@ def test_install_from_tar_gz_no_manifest(self, project_dir, temp_dir):
11171117

11181118
def test_install_from_tar_gz_rejects_path_traversal(self, project_dir, temp_dir):
11191119
"""install_from_zip must reject tarballs with path traversal entries."""
1120-
import tarfile, io
1120+
import tarfile
1121+
import io
11211122
archive = temp_dir / "evil.tar.gz"
11221123
with tarfile.open(archive, "w:gz") as tf:
11231124
info = tarfile.TarInfo(name="../../evil.txt")

tests/test_presets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ def test_install_from_tar_gz_nested(self, project_dir, pack_dir, temp_dir):
691691

692692
def test_install_from_tar_gz_no_manifest(self, project_dir, temp_dir):
693693
"""Test installing a preset from a .tar.gz without preset.yml raises error."""
694-
import tarfile, io
694+
import tarfile
695+
import io
695696
archive = temp_dir / "bad.tar.gz"
696697
with tarfile.open(archive, "w:gz") as tf:
697698
data = b"no manifest here"
@@ -705,7 +706,8 @@ def test_install_from_tar_gz_no_manifest(self, project_dir, temp_dir):
705706

706707
def test_install_from_tar_gz_rejects_path_traversal(self, project_dir, temp_dir):
707708
"""install_from_zip must reject tarballs with path traversal entries."""
708-
import tarfile, io
709+
import tarfile
710+
import io
709711
archive = temp_dir / "evil.tar.gz"
710712
with tarfile.open(archive, "w:gz") as tf:
711713
info = tarfile.TarInfo(name="../../evil.txt")

0 commit comments

Comments
 (0)