Skip to content

Bug fix of __r<magic_methods>__ being used under the same __<magic_method>__ hook#18995

Merged
JukkaL merged 7 commits into
python:masterfrom
arnav-jain1:master
May 1, 2025
Merged

Bug fix of __r<magic_methods>__ being used under the same __<magic_method>__ hook#18995
JukkaL merged 7 commits into
python:masterfrom
arnav-jain1:master

Conversation

@arnav-jain1

@arnav-jain1 arnav-jain1 commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Fixes #18945 (This was a feature request that turned out to be a bug)

Essentially, I was trying to create a custom plugin and implement add. In the process I discovered that radd would implicitly be called if add has an error but it would be called under the same add hook (instead of radd) which is bad for non-commutative operations. This has been fixed.
I also added a test for it.

@github-actions

This comment has been minimized.

@arnav-jain1

Copy link
Copy Markdown
Contributor Author

yippee

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@arnav-jain1

Copy link
Copy Markdown
Contributor Author

Yippee

@sterliakov

Copy link
Copy Markdown
Collaborator

@hauntsaninja could you post/link this to #6617 (it's locked, I can't write there)? I don't think this breaks someone's workflow, but better be cautious.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A way to prevent MyPy from implictly checking the __r<magic method>__

3 participants