ruff
7c32e98d - Use unused variable detection to power `incorrect-dict-iterator` (#5763)

Commit
2 years ago
Use unused variable detection to power `incorrect-dict-iterator` (#5763) ## Summary `PERF102` looks for unused keys or values in `dict.items()` calls, and suggests instead using `dict.keys()` or `dict.values()`. Previously, this check determined usage by looking for underscore-prefixed variables. However, we can use the semantic model to actually detect whether a variable is used. This has two nice effects: 1. We avoid odd false-positives whereby underscore-prefixed variables are actually used. 2. We can catch more cases (fewer false-negatives) by detecting unused loop variables that _aren't_ underscore-prefixed. Closes #5692.
Author
Parents
Loading