-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Incorrect type inference with __radd__
of tuple subtype against literal tuples.
#19006
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
Labels
bug
mypy got something wrong
Comments
Ohh, this is interesting! Lines 3487 to 3516 in c724a6a
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
mypy
generally correctly prioritizes__radd__
if the right operand is a subtype of the left operand. However, I discovered that it can fail to do so when testing against tuple literals.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=2a3598efce6ff75cad67822cb5436b53
The bug does seem to be tuple-specific, for instance it does not appear with integer literals: https://mypy-play.net/?mypy=latest&python=3.12&gist=da0763e25cd0654d1a8b8b0b67291bc5
Expected Behavior
All
assert_type
in the example above should succeed.The text was updated successfully, but these errors were encountered: