You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comparison operators emit "Unsupported operand types" when using isinstance to narrow TypeVar to union of numeric types #19454
I have a generic class that wraps a bool, float, int, or str. It implements the comparison operator magic methods like __lt__ etc., using isinstance to ensure that callers don't mix bool/float/int with str. With mypy 1.16.1, this does not error, but with mypy 1.17.0, the comparison operators started emitting "error: Unsupported operand types for < (likely involving Union) [operator]"
Activity
sterliakov commentedon Jul 16, 2025
This was exposed by #19183 due to narrowing (which is now correct), and the MRE is
https://mypy-play.net/?mypy=master&python=3.12&gist=01ea3e0ed462cc2b1deee8bc40c25ac9
Merge remote-tracking branch 'upstream/master' into bugfix/pythongh-1…
Merge branch 'master' into bugfix/pythongh-19454-ops-on-typevr