mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
## 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.