Skip to content

Possible false negative on PLR1736 #13183

@sbrugman

Description

@sbrugman

The following example I would expect to be recognised by PLR1736

Minimal reproducible example:

data = {"a": 1, "b": 2}
column_names = ["a", "b"]
for index, column_name in enumerate(column_names):
    _ = data[column_names[index]]

Command:

ruff check --isolated --select PLR1736 examples/plr.py

Output:

All checks passed!

Expected output:

examples/plr.py:8:8: PLR1736 [*] List index lookup in `enumerate()` loop
  |
7 | for index, column_name in enumerate(column_names):
8 |     _ = data[column_names[index]]
  |             ^^^^^^^^^^^^^^^^^^^^ PLR1736
  |
  = help: Use the loop variable directly

Version: ruff 0.6.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingruleImplementing 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