Skip to content

docs: fix PLR0124 description to acknowledge __eq__ can be overridden#24717

Closed
avasis-ai wants to merge 1 commit intoastral-sh:mainfrom
avasis-ai:fix-plr0124-doc-wording
Closed

docs: fix PLR0124 description to acknowledge __eq__ can be overridden#24717
avasis-ai wants to merge 1 commit intoastral-sh:mainfrom
avasis-ai:fix-plr0124-doc-wording

Conversation

@avasis-ai
Copy link
Copy Markdown
Contributor

Summary

Fixes the documentation for comparison-with-itself (PLR0124) to acknowledge that __eq__ may be overridden to return a non-trivial value, making self-comparisons not always redundant.

The previous wording stated that "Comparing a name to itself always results in the same value", which is incorrect when __eq__ is overridden.

Closes #22160

Test Plan

Documentation-only change. The rule logic is unchanged.

@astral-sh-bot astral-sh-bot Bot requested a review from ntBre April 19, 2026 16:51
Comment on lines +15 to +16
/// Comparing a name to itself is likely a mistake, as `__eq__` may be
/// overridden to return a non-trivial value.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is quite the change we were picturing. This phrasing suggests that __eq__ returning an unusual value causes the issue, but the opposite is true. The lint rule applies except when you've overriden __eq__ to return something weird.

@ntBre ntBre added the documentation Improvements or additions to documentation label Apr 20, 2026
@avasis-ai
Copy link
Copy Markdown
Contributor Author

You're right, my previous phrasing was backwards. Updated to match the issue author's suggestion: Comparing a name to itself typically results in a truthy value, and is likely a mistake.

@avasis-ai
Copy link
Copy Markdown
Contributor Author

Closing in favor of updated fix on a clean branch.

@avasis-ai avasis-ai closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLR0124 Documentation Issue

3 participants