[pylint] Ignore identical members (PLR1714)#22220
Merged
ntBre merged 2 commits intoastral-sh:mainfrom Jan 2, 2026
Merged
Conversation
|
ntBre
reviewed
Jan 2, 2026
Contributor
ntBre
left a comment
There was a problem hiding this comment.
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
approved these changes
Jan 2, 2026
| continue; | ||
| } | ||
|
|
||
| if let Some((&first, rest)) = comparators.split_first() { |
...nt/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap
Show resolved
Hide resolved
njhearp
commented
Jan 2, 2026
|
|
||
| foo == 0.0 or foo == 0j # Different types, same hashed value | ||
|
|
||
| foo == "bar" or foo == "bar" # All members identical |
Contributor
Author
There was a problem hiding this comment.
I think we should consider a rule to get this to reduce to foo == "bar". Opening a separate issue would probably be best.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.