Skip to content

Commit 0924490

Browse files
fix: Use 3.9 compatible zip (#15177)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary Uses a <3.10-compatible version of `zip` since the `strict` argument was [added in 3.10](https://docs.python.org/3.10/library/functions.html#zip) ## Test Plan I executed the `_matching_parents` function in a local 3.9 environment --------- Co-authored-by: Zanie Blue <contact@zanie.dev>
1 parent 6b5d309 commit 0924490

2 files changed

Lines changed: 14 additions & 24 deletions

File tree

‎crates/uv/tests/it/python_module.rs‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,14 @@ fn find_uv_bin_py38() {
412412
// We should find the binary in the virtual environment
413413
uv_snapshot!(context.filters(), context.python_command()
414414
.arg("-c")
415-
.arg("import uv; print(uv.find_uv_bin())"), @r#"
416-
success: false
417-
exit_code: 1
415+
.arg("import uv; print(uv.find_uv_bin())"), @r"
416+
success: true
417+
exit_code: 0
418418
----- stdout -----
419+
[VENV]/[BIN]/uv
419420
420421
----- stderr -----
421-
Traceback (most recent call last):
422-
File "<string>", line 1, in <module>
423-
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
424-
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
425-
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
426-
for part, match_part in zip(
427-
TypeError: zip() takes no keyword arguments
428-
"#
422+
"
429423
);
430424
}
431425

@@ -458,20 +452,14 @@ fn find_uv_bin_py39() {
458452
// We should find the binary in the virtual environment
459453
uv_snapshot!(context.filters(), context.python_command()
460454
.arg("-c")
461-
.arg("import uv; print(uv.find_uv_bin())"), @r#"
462-
success: false
463-
exit_code: 1
455+
.arg("import uv; print(uv.find_uv_bin())"), @r"
456+
success: true
457+
exit_code: 0
464458
----- stdout -----
459+
[VENV]/[BIN]/uv
465460
466461
----- stderr -----
467-
Traceback (most recent call last):
468-
File "<string>", line 1, in <module>
469-
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
470-
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
471-
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
472-
for part, match_part in zip(
473-
TypeError: zip() takes no keyword arguments
474-
"#
462+
"
475463
);
476464
}
477465

‎python/uv/_find_uv.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ def _matching_parents(path: str | None, match: str) -> str | None:
7676

7777
if not all(
7878
fnmatch(part, match_part)
79-
for part, match_part in zip(
80-
reversed(parts), reversed(match_parts), strict=False
79+
for part, match_part in (
80+
zip(reversed(parts), reversed(match_parts), strict=False)
81+
if sys.version_info >= (3, 10)
82+
else zip(reversed(parts), reversed(match_parts)) # noqa: B905
8183
)
8284
):
8385
return None

0 commit comments

Comments
 (0)