zip-without-explicit-strict
What it does
Section titled “What it does”Reports a call of zip with several arguments (or a starred one) and no strict keyword, for a target_version of 3.10 and later.
Why it matters
Section titled “Why it matters”zip stops at the shortest argument and drops the rest without a message. When the arguments are meant to have one length, a bug that makes one shorter is lost. strict=True raises ValueError, and strict=False says that cutting is intended.
To fix, add strict=True, or strict=False when the lengths may differ.
Example
Section titled “Example”...y = setattr(x, "name", 1)setattr(x, "class", 1)zip(a, b)zip(a)zip(a, b, strict=True)try:...Configuration
Section titled “Configuration”python: lint: rules: zip-without-explicit-strict: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line zip-without-explicit-strict in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | B905 |
full |