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
Incorrect narrowing between two different unions #20820
Narrowing via isinstance and two unions does not seem to do a full crossproduct of possibilities. Spotted when reviewing #20743.
To Reproduce
from __future__ importannotationsclassA: ...
classB: ...
classC: ...
deff1(x: A|C, t: type[A] |type[B]):
ifisinstance(x, t):
reveal_type(x) # N: Revealed type is "__main__.A"else:
reveal_type(x) # Revealed type is "__main__.A | __main__.C"
Expected Behavior
I would expect the revealed types to be a superset of the results if we did a crossproduct. However, note that <subclass of C and B> is missing. (probably the best way to express this would be to have intersections but... yeah...)
Actual Behavior
Positive branch just has A.
Your Environment
Reproduced in mypy-play
Mypy version used: master
Mypy command-line flags: N/A
Mypy configuration options from mypy.ini (and other config files): N/A
Activity
Fix issue python#20820
BHUVANSH855 commentedon Apr 12, 2026
Hi @A5rocks I’d like to work on this issue.
I noticed there was a previous attempt (#20824). I’ll review it and try to address any gaps or concerns from that PR.
Please let me know if there are any specific expectations before I proceed.
A5rocks commentedon Apr 12, 2026
You can work on whatever, no need for permission.