Skip to content

Commit b3b5f92

Browse files
committed
Add an explicit test for changed behaviour of enum/union overlap
1 parent ac0d9cb commit b3b5f92

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/unit/check-typeis.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,3 +936,19 @@ def func(arg: Any) -> None:
936936
if is_dataclass(arg):
937937
reveal_type(arg) # N: Revealed type is "Union[Type[__main__.DataclassInstance], __main__.DataclassInstance]"
938938
[builtins fixtures/tuple.pyi]
939+
940+
[case testTypeIsEnumOverlappingUnionExcludesIrrelevant]
941+
from enum import Enum
942+
from typing import Literal
943+
from typing_extensions import TypeIs
944+
945+
class Model(str, Enum):
946+
A = 'a'
947+
B = 'a'
948+
949+
def is_model_a(model: str) -> TypeIs[Literal[Model.A, "foo"]]:
950+
return True
951+
def handle(model: Model) -> None:
952+
if is_model_a(model):
953+
reveal_type(model) # N: Revealed type is "Literal[__main__.Model.A]"
954+
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)