-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
featurepriority-2-lowtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
I would expect the type of either
to be narrowed to Maybe
in the if
block.
from typing import Literal
class Maybe:
def should(self) -> bool:
...
class No:
def should(self) -> Literal[False]:
...
no: No
if no.should():
reveal_type(no) # error: unreachable
either: Maybe | No
if either.should():
reveal_type(either) # Maybe | No
DetachHead and finite-state-machine
Metadata
Metadata
Assignees
Labels
featurepriority-2-lowtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder