unnecessary-dict-index-lookup (PLR1733)
Added in 0.12.0 · Related issues · View source
Derived from the Pylint linter.
Fix is always available.
What it does
Checks for key-based dict accesses during .items() iterations.
Why is this bad?
When iterating over a dict via .items(), the current value is already
available alongside its key. Using the key to look up the value is
unnecessary.
Example
FRUITS = {"apple": 1, "orange": 10, "berry": 22}
for fruit_name, fruit_count in FRUITS.items():
print(FRUITS[fruit_name])
Use instead: