mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
## Summary <!-- What's the purpose of the change? What does it do, and why? --> This PR implements the [consider dict items](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/consider-using-dict-items.html) rule from Pylint. Enabling this rule flags: ```python ORCHESTRA = { "violin": "strings", "oboe": "woodwind", "tuba": "brass", "gong": "percussion", } for instrument in ORCHESTRA: print(f"{instrument}: {ORCHESTRA[instrument]}") for instrument in ORCHESTRA.keys(): print(f"{instrument}: {ORCHESTRA[instrument]}") for instrument in (inline_dict := {"foo": "bar"}): print(f"{instrument}: {inline_dict[instrument]}") ``` For not using `items()` to extract the value out of the dict. We ignore the case of an assignment, as you can't modify the underlying representation with the value in the list of tuples returned. ## Test Plan <!-- How was it tested? --> `cargo test`. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>