basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

union with intersection doesn't narrow properly

Open KotlinIsland opened this issue 1 year ago • 0 comments

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

KotlinIsland avatar Aug 28 '24 03:08 KotlinIsland