-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pylint
] Implement consider-dict-items
(C0206
)
#11688
[pylint
] Implement consider-dict-items
(C0206
)
#11688
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLC0206 | 35 | 35 | 0 | 0 | 0 |
@charliermarsh Any chance you might be able to take a look? |
Interesting, I swear we have a rule for this... But maybe we don't? I see:
|
Yeah, a little different since this one doesn't rely on you using items before. |
pylint
] Implement dict-iter-missing-items
(C0206
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I reviewed the ecosystem checks and they look right to me. |
Thanks for the clean up! Still getting used to writing more Rust code haha |
No prob! One thing I did in a few places was change |
dict_index_missing_items.py:9:1: PLC0206 Extracting value from dictionary without calling `.items()` | ||
| | ||
8 | # Errors | ||
9 | / for instrument in ORCHESTRA: | ||
10 | | print(f"{instrument}: {ORCHESTRA[instrument]}") | ||
| |___________________________________________________^ PLC0206 | ||
11 | | ||
12 | for instrument in ORCHESTRA: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be quite useful to have a infrastructure to provide additional details here similar to Biome. That would avoid highlighting the entire for
statement and instead we could highlight individual pieces of code with details.
pylint
] Implement dict-iter-missing-items
(C0206
)pylint
] Implement consider-dict-items
(C0206
)
Summary
This PR implements the consider dict items rule from Pylint. Enabling this rule flags:
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
cargo test
.