@@ -754,35 +754,46 @@ if sys.version_info[0] >= 2:
754
754
reveal_type('') # N: Revealed type is "Literal['']?"
755
755
[builtins fixtures/ops.pyi]
756
756
757
- [case testUnreachableFlagWithBadControlFlow ]
757
+ [case testUnreachableFlagWithBadControlFlow1 ]
758
758
# flags: --warn-unreachable
759
759
a: int
760
760
if isinstance(a, int):
761
761
reveal_type(a) # N: Revealed type is "builtins.int"
762
762
else:
763
763
reveal_type(a) # E: Statement is unreachable
764
+ [builtins fixtures/isinstancelist.pyi]
764
765
766
+ [case testUnreachableFlagWithBadControlFlow2]
767
+ # flags: --warn-unreachable
765
768
b: int
766
769
while isinstance(b, int):
767
770
reveal_type(b) # N: Revealed type is "builtins.int"
768
771
else:
769
772
reveal_type(b) # E: Statement is unreachable
773
+ [builtins fixtures/isinstancelist.pyi]
770
774
775
+ [case testUnreachableFlagWithBadControlFlow3]
776
+ # flags: --warn-unreachable
771
777
def foo(c: int) -> None:
772
778
reveal_type(c) # N: Revealed type is "builtins.int"
773
779
assert not isinstance(c, int)
774
780
reveal_type(c) # E: Statement is unreachable
781
+ [builtins fixtures/isinstancelist.pyi]
775
782
783
+ [case testUnreachableFlagWithBadControlFlow4]
784
+ # flags: --warn-unreachable
776
785
d: int
777
786
if False:
778
787
reveal_type(d) # E: Statement is unreachable
788
+ [builtins fixtures/isinstancelist.pyi]
779
789
790
+ [case testUnreachableFlagWithBadControlFlow5]
791
+ # flags: --warn-unreachable
780
792
e: int
781
793
if True:
782
794
reveal_type(e) # N: Revealed type is "builtins.int"
783
795
else:
784
796
reveal_type(e) # E: Statement is unreachable
785
-
786
797
[builtins fixtures/isinstancelist.pyi]
787
798
788
799
[case testUnreachableFlagStatementAfterReturn]
@@ -1390,3 +1401,18 @@ def f() -> None:
1390
1401
if nope():
1391
1402
x = 1 # E: Statement is unreachable
1392
1403
[builtins fixtures/dict.pyi]
1404
+
1405
+ [case testUnreachableModuleBody1]
1406
+ # flags: --warn-unreachable
1407
+ from typing import NoReturn
1408
+ def foo() -> NoReturn:
1409
+ raise Exception("foo")
1410
+ foo()
1411
+ x = 1 # E: Statement is unreachable
1412
+ [builtins fixtures/exception.pyi]
1413
+
1414
+ [case testUnreachableModuleBody2]
1415
+ # flags: --warn-unreachable
1416
+ raise Exception
1417
+ x = 1 # E: Statement is unreachable
1418
+ [builtins fixtures/exception.pyi]
0 commit comments