basedmypy
basedmypy copied to clipboard
union with intersection doesn't narrow properly
upstream issue, but:
class A: ...
class B: ...
class C: ...
other: (A & B) | C
data: B | C
data = other
if isinstance(data, A):
reveal_type(data) # Never
should be (A & B) | (A & C)
interestingly, this only occurs when it's narrowed and doesn't happen when you specify the type explicitly data: (A & B) | C