Skip to content

zip-without-explicit-strict

Pythonsuspiciousno fixdefault: off

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.

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.

Reported
...
y = setattr(x, "name", 1)
setattr(x, "class", 1)
zip(a, b)
zip(a)
zip(a, b, strict=True)
try:
...
python:
lint:
rules:
zip-without-explicit-strict: warn # off (default), warn, error

Suppress one line with sudsy-disable-next-line zip-without-explicit-strict in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff B905 full