-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[pylint] Ignore identical members (PLR1714)
#22220
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
Conversation
|
ntBre
left a comment
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.
Thank you!
I just had one nit about the indexing and a question about the second test case, but this looks great.
crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs
Outdated
Show resolved
Hide resolved
...nt/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap
Show resolved
Hide resolved
ntBre
left a comment
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.
Thank you!
| continue; | ||
| } | ||
|
|
||
| if let Some((&first, rest)) = comparators.split_first() { |
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.
Nice!
...nt/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap
Show resolved
Hide resolved
|
|
||
| foo == 0.0 or foo == 0j # Different types, same hashed value | ||
|
|
||
| foo == "bar" or foo == "bar" # All members identical |
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.
I think we should consider a rule to get this to reduce to foo == "bar". Opening a separate issue would probably be best.
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.
Summary
This PR closes #21692.
PLR1714will no longer flag if all members are identical. I iterate through the equality comparisons and if they are all equal the rule does not flag.Test Plan
Additional tests were added with identical members.