Skip to content

zip-without-explicit-strict (B905)#

Derived from the flake8-bugbear linter.

What it does#

Checks for zip calls without an explicit strict parameter.

Why is this bad?#

By default, if the iterables passed to zip are of different lengths, the resulting iterator will be silently truncated to the length of the shortest iterable. This can lead to subtle bugs.

Use the strict parameter to raise a ValueError if the iterables are of non-uniform length.


zip(a, b)

Use instead:

zip(a, b, strict=True)