-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
featuretopic-enumtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
from typing import NoReturn, Literal
from enum import auto, Enum
def foo(value: Literal["foo","bar"]) -> None:
if value == "foo":
reveal_type(value) #note: Revealed type is "Literal['foo']"
elif value != "bar":
reveal_type(value) #error: Statement is unreachable [unreachable]
class Foo(Enum):
foo = auto()
bar = auto()
def bar(value: Foo) -> None:
if value == Foo.foo:
reveal_type(value) #Revealed type is "__main__.Foo"
elif value != Foo.bar:
reveal_type(value) #no error, even though this is unreachable
KotlinIsland and schneiderfelipe
Metadata
Metadata
Assignees
Labels
featuretopic-enumtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder