@@ -866,6 +866,7 @@ main:2: note: Revealed type is "Literal[1]?"
866866main:2: note: Revealed type is "Literal['foo']?"
867867
868868[case testEnumReachabilityChecksBasic]
869+ # flags: --warn-unreachable
869870from enum import Enum
870871from typing import Literal
871872
@@ -882,7 +883,7 @@ elif x is Foo.B:
882883elif x is Foo.C:
883884 reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.C]"
884885else:
885- reveal_type(x) # No output here: this branch is unreachable
886+ reveal_type(x) # E: Statement is unreachable
886887reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.A] | Literal[__main__.Foo.B] | Literal[__main__.Foo.C]"
887888
888889if Foo.A is x:
@@ -892,7 +893,7 @@ elif Foo.B is x:
892893elif Foo.C is x:
893894 reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.C]"
894895else:
895- reveal_type(x) # No output here: this branch is unreachable
896+ reveal_type(x) # E: Statement is unreachable
896897reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.A] | Literal[__main__.Foo.B] | Literal[__main__.Foo.C]"
897898
898899y: Foo
@@ -903,7 +904,7 @@ elif y is Foo.B:
903904elif y is Foo.C:
904905 reveal_type(y) # N: Revealed type is "Literal[__main__.Foo.C]"
905906else:
906- reveal_type(y) # No output here: this branch is unreachable
907+ reveal_type(y) # E: Statement is unreachable
907908reveal_type(y) # N: Revealed type is "__main__.Foo"
908909
909910if Foo.A is y:
@@ -913,11 +914,12 @@ elif Foo.B is y:
913914elif Foo.C is y:
914915 reveal_type(y) # N: Revealed type is "Literal[__main__.Foo.C]"
915916else:
916- reveal_type(y) # No output here: this branch is unreachable
917+ reveal_type(y) # E: Statement is unreachable
917918reveal_type(y) # N: Revealed type is "__main__.Foo"
918919[builtins fixtures/bool.pyi]
919920
920921[case testEnumReachabilityChecksWithOrdering]
922+ # flags: --warn-unreachable
921923from enum import Enum
922924from typing import Literal
923925
@@ -934,7 +936,7 @@ if x is Foo.A:
934936elif x is Foo.B:
935937 reveal_type(x) # N: Revealed type is "Literal[__main__.Foo.B]"
936938else:
937- reveal_type(x) # No output here: this branch is unreachable
939+ reveal_type(x) # E: Statement is unreachable
938940
939941class Bar(Enum):
940942 __order__ = "A B"
@@ -949,26 +951,27 @@ if y is Bar.A:
949951elif y is Bar.B:
950952 reveal_type(y) # N: Revealed type is "Literal[__main__.Bar.B]"
951953else:
952- reveal_type(y) # No output here: this branch is unreachable<
10BC0
/div>
954+ reveal_type(y) # E: Statement is unreachable
953955
954956x2: Foo
955957if x2 is Foo.A:
956958 reveal_type(x2) # N: Revealed type is "Literal[__main__.Foo.A]"
957959elif x2 is Foo.B:
958960 reveal_type(x2) # N: Revealed type is "Literal[__main__.Foo.B]"
959961else:
960- reveal_type(x2) # No output here: this branch is unreachable
962+ reveal_type(x2) # E: Statement is unreachable
961963
962964y2: Bar
963965if y2 is Bar.A:
964966 reveal_type(y2) # N: Revealed type is "Literal[__main__.Bar.A]"
965967elif y2 is Bar.B:
966968 reveal_type(y2) # N: Revealed type is "Literal[__main__.Bar.B]"
967969else:
968- reveal_type(y2) # No output here: this branch is unreachable
970+ reveal_type(y2) # E: Statement is unreachable
969971[builtins fixtures/tuple.pyi]
970972
971973[case testEnumReachabilityChecksIndirect]
974+ # flags: --warn-unreachable
972975from enum import Enum
973976from typing import Final, Literal
974977
@@ -1022,18 +1025,19 @@ if y is z:
10221025 reveal_type(z) # N: Revealed type is "Literal[__main__.Foo.A]?"
10231026 accepts_foo_a(z)
10241027else:
1025- reveal_type(y) # No output: this branch is unreachable
1026- reveal_type(z) # No output: this branch is unreachable
1028+ reveal_type(y) # E: Statement is unreachable
1029+ reveal_type(z)
10271030if z is y:
10281031 reveal_type(y) # N: Revealed type is "Literal[__main__.Foo.A]"
10291032 reveal_type(z) # N: Revealed type is "Literal[__main__.Foo.A]?"
10301033 accepts_foo_a(z)
10311034else:
1032- reveal_type(y) # No output: this branch is unreachable
1033- reveal_type(z) # No output: this branch is unreachable
1035+ reveal_type(y) # E: Statement is unreachable
1036+ reveal_type(z)
10341037[builtins fixtures/bool.pyi]
10351038
10361039[case testEnumReachabilityNarrowingForUnionMessiness]
1040+ # flags: --warn-unreachable
10371041from enum import Enum
10381042from typing import Literal
10391043
@@ -1062,6 +1066,7 @@ else:
10621066[builtins fixtures/bool.pyi]
10631067
10641068[case testEnumReachabilityWithNone]
1069+ # flags: --warn-unreachable
10651070from enum import Enum
10661071from typing import Optional
10671072
@@ -1089,6 +1094,7 @@ reveal_type(x) # N: Revealed type is "__main__.Foo | None"
10891094[builtins fixtures/enum.pyi]
10901095
10911096[case testEnumReachabilityWithMultipleEnums]
1097+ # flags: --warn-unreachable
10921098from enum import Enum
10931099from typing import Literal, Union
10941100
@@ -1123,6 +1129,7 @@ reveal_type(x3) # N: Revealed type is "__main__.Foo | __main__.Bar"
11231129[builtins fixtures/bool.pyi]
11241130
11251131[case testEnumReachabilityPEP484ExampleWithFinal]
1132+ # flags: --warn-unreachable
11261133from typing import Final, Union
11271134from enum import Enum
11281135
@@ -1146,6 +1153,7 @@ def func(x: Union[int, None, Empty] = _empty) -> int:
11461153[builtins fixtures/primitives.pyi]
11471154
11481155[case testEnumReachabilityPEP484ExampleWithMultipleValues]
1156+ # flags: --warn-unreachable
11491157from typing import Union
11501158from enum import Enum
11511159
@@ -1168,6 +1176,7 @@ def process(response: Union[str, Reason] = '') -> str:
11681176
11691177
11701178[case testEnumReachabilityPEP484ExampleSingleton]
1179+ # flags: --warn-unreachable
11711180from typing import Final, Union
11721181from enum import Enum
11731182
@@ -1191,7 +1200,7 @@ def func(x: Union[int, None, Empty] = _empty) -> int:
11911200[builtins fixtures/primitives.pyi]
11921201
11931202[case testEnumReachabilityPEP484ExampleSingletonWithMethod]
1194- # flags: --python-version 3.11
1203+ # flags: --python-version 3.11 --warn-unreachable
11951204from typing import Final, Union
11961205from enum import Enum, member
11971206
@@ -1232,6 +1241,7 @@ reveal_type(A().b) # N: Revealed type is "Any"
12321241[builtins fixtures/enum.pyi]
12331242
12341243[case testEnumReachabilityWithChaining]
1244+ # flags: --warn-unreachable
12351245from enum import Enum
12361246
12371247class Foo(Enum):
0 commit comments