@@ -2722,7 +2722,7 @@ while True:
27222722 break
27232723 x = str()
27242724 if x == int(): # E: Non-overlapping equality check (left operand type: "str", right operand type: "int")
2725- break
2725+ break # E: Statement is unreachable
27262726[builtins fixtures/primitives.pyi]
27272727
27282728[case testAvoidFalseNonOverlappingEqualityCheckInLoop2]
@@ -2735,7 +2735,7 @@ class C: ...
27352735x = A()
27362736while True:
27372737 if x == C(): # E: Non-overlapping equality check (left operand type: "A | B", right operand type: "C")
2738- break
2738+ break # E: Statement is unreachable
27392739 x = B()
27402740[builtins fixtures/primitives.pyi]
27412741
@@ -3127,7 +3127,7 @@ def narrow_tuple(x: Literal['c'], overlap: list[Literal['b', 'c']], no_overlap:
31273127 reveal_type(x) # N: Revealed type is "Literal['c']"
31283128
31293129 if x in no_overlap:
3130- reveal_type(x) # N: Revealed type is "Literal['c']"
3130+ reveal_type(x) # E: Statement is unreachable
31313131 else:
31323132 reveal_type(x) # N: Revealed type is "Literal['c']"
31333133[builtins fixtures/tuple.pyi]
@@ -3169,8 +3169,8 @@ def f2(x: Any) -> None:
31693169
31703170def bad_compare_has_key(has_key: bool, key: str, s: tuple[str, ...]) -> None:
31713171 if has_key == key in s: # E: Non-overlapping equality check (left operand type: "bool", right operand type: "str")
3172- reveal_type(has_key) # N: Revealed type is "builtins.bool"
3173- reveal_type(key) # N: Revealed type is "builtins.str"
3172+ reveal_type(has_key) # E: Statement is unreachable
3173+ reveal_type(key)
31743174
31753175def bad_but_should_pass(has_key: bool, key: bool, s: tuple[bool, ...]) -> None:
31763176 if has_key == key in s:
@@ -3537,6 +3537,7 @@ def bar(y: Any):
35373537 reveal_type(y) # N: Revealed type is "Any"
35383538[builtins fixtures/dict-full.pyi]
35393539
3540+
35403541[case testNarrowTypeVarType]
35413542# flags: --strict-equality --warn-unreachable
35423543from typing import TypeVar
@@ -3567,14 +3568,14 @@ TargetType = TypeVar("TargetType", int, float, str)
35673568# TODO: this behaviour is incorrect, it will be fixed by improving reachability
35683569def convert_type(target_type: Type[TargetType]) -> TargetType:
35693570 if target_type == str:
3570- return str() # E: Incompatible return value type (got "str", expected "int") \
3571- # E: Incompatible return value type (got "str", expected "float")
3571+ return str()
35723572 if target_type == int:
3573- return int() # E: Incompatible return value type (got "int", expected "str")
3573+ return int()
35743574 if target_type == float:
3575- return float() # E: Incompatible return value type (got "float", expected "int") \
3576- # E: Incompatible return value type (got "float", expected "str")
3575+ return float() # E: Incompatible return value type (got "float", expected "int")
35773576 raise
3577+
3578+
35783579[builtins fixtures/primitives.pyi]
35793580
35803581
0 commit comments