-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
zip-without-explicit-strict (B905) reports diagnostics for zip calls with less than two positional arguments, which is unnecessary. strict can only make a difference when there are two or more positional arguments, or any starred positional arguments. Compare map-without-explicit-strict (B912), which is only triggered when there are two or more positional arguments. Example:
$ cat >b905.py <<'# EOF'
print(tuple(zip()))
print(tuple(zip("abc")))
print(tuple(map(lambda x: x, "abc")))
# EOF
$ python b905.py
()
(('a',), ('b',), ('c',))
('a', 'b', 'c')
$ ruff --isolated check b905.py --select B905,B912 --target-version py314 --preview --unsafe-fixes --diff
--- b905.py
+++ b905.py
@@ -1,4 +1,4 @@
-print(tuple(zip()))
-print(tuple(zip("abc")))
+print(tuple(zip(strict=False)))
+print(tuple(zip("abc", strict=False)))
print(tuple(map(lambda x: x, "abc")))
Would fix 2 errors.Version
ruff 0.14.1 (2bffef5 2025-10-16)
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule