Skip to content

B905's autofix sets strict=False, but the suggested fix is strict=True #13581

@mdbernard

Description

@mdbernard

The docs for B905 state the suggested fix is to use strict=True, but the autofix introduced here autofixes with strict=False.

Either the docs or the autofix should be updated to match the other.

I would argue that the autofix should be changed to strict=True, since that is the option less likely to cause unexpected runtime behavior for users. It might cause runtime exceptions to be raised, but I personally would prefer those to silently continuing with potentially unintended behavior.


Keywords: B905, zip-without-explicit-strict

Current ruff version: 0.6.6

Minimal snippet:

zip(a, b)

Command invoked:
ruff check example.py --target-version=py311 --select=B905

Output:

example.py:1:1: B905 [*] `zip()` without an explicit `strict=` parameter
  |
1 | zip(a, b)
  | ^^^^^^^^^ B905
  |
  = help: Add explicit `strict=False`

Found 1 error.
[*] 1 fixable with the `--fix` option.

Expected output:

...
  = help: Add explicit `strict=True`
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions