Skip to content

Conversation

@njhearp
Copy link
Contributor

@njhearp njhearp commented Dec 27, 2025

Summary

This PR closes #21692. PLR1714 will 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.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 27, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre self-requested a review December 29, 2025 14:18
Copy link
Contributor

@ntBre ntBre left a 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.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Jan 2, 2026
Copy link
Contributor

@ntBre ntBre left a 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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@ntBre ntBre merged commit 0804030 into astral-sh:main Jan 2, 2026
40 checks passed

foo == 0.0 or foo == 0j # Different types, same hashed value

foo == "bar" or foo == "bar" # All members identical
Copy link
Contributor Author

@njhearp njhearp Jan 2, 2026

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is possibly tracked in #21690. Micha mentioned a more general unreachable rule there and on #21692.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLR1714: Repeated equality comparison to the same literal value shouldn't convert to a set

2 participants