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>
This commit is contained in:
Dustin Ngo
2025-08-08 19:45:13 -04:00
committed by GitHub
parent 6b5d309d28
commit 0924490456
2 changed files with 14 additions and 24 deletions
+10 -22
View File
@@ -412,20 +412,14 @@ fn find_uv_bin_py38() {
// We should find the binary in the virtual environment
uv_snapshot!(context.filters(), context.python_command()
.arg("-c")
.arg("import uv; print(uv.find_uv_bin())"), @r#"
success: false
exit_code: 1
.arg("import uv; print(uv.find_uv_bin())"), @r"
success: true
exit_code: 0
----- stdout -----
[VENV]/[BIN]/uv
----- stderr -----
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
for part, match_part in zip(
TypeError: zip() takes no keyword arguments
"#
"
);
}
@@ -458,20 +452,14 @@ fn find_uv_bin_py39() {
// We should find the binary in the virtual environment
uv_snapshot!(context.filters(), context.python_command()
.arg("-c")
.arg("import uv; print(uv.find_uv_bin())"), @r#"
success: false
exit_code: 1
.arg("import uv; print(uv.find_uv_bin())"), @r"
success: true
exit_code: 0
----- stdout -----
[VENV]/[BIN]/uv
----- stderr -----
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "[SITE_PACKAGES]/uv/_find_uv.py", line 28, in find_uv_bin
_matching_parents(_module_path(), "lib/[PYTHON]*/site-packages/uv"), "bin"
File "[SITE_PACKAGES]/uv/_find_uv.py", line 79, in _matching_parents
for part, match_part in zip(
TypeError: zip() takes no keyword arguments
"#
"
);
}
+4 -2
View File
@@ -76,8 +76,10 @@ def _matching_parents(path: str | None, match: str) -> str | None:
if not all(
fnmatch(part, match_part)
for part, match_part in zip(
reversed(parts), reversed(match_parts), strict=False
for part, match_part in (
zip(reversed(parts), reversed(match_parts), strict=False)
if sys.version_info >= (3, 10)
else zip(reversed(parts), reversed(match_parts)) # noqa: B905
)
):
return None