@@ -3264,6 +3264,39 @@ def bad_but_should_pass(has_key: bool, key: bool, s: tuple[bool, ...]) -> None:
32643264 reveal_type(key) # N: Revealed type is "builtins.bool"
32653265[builtins fixtures/primitives.pyi]
32663266
3267+ [case testNarrowChainedComparisonMeet]
3268+ # flags: --strict-equality --warn-unreachable
3269+ from __future__ import annotations
3270+ from typing import Any
3271+
3272+ def f1(a: str | None, b: str | None) -> None:
3273+ if None is not a == b:
3274+ reveal_type(a) # N: Revealed type is "builtins.str"
3275+ reveal_type(b) # N: Revealed type is "builtins.str | None"
3276+
3277+ if (None is not a) and (a == b):
3278+ reveal_type(a) # N: Revealed type is "builtins.str"
3279+ reveal_type(b) # N: Revealed type is "builtins.str"
3280+
3281+ def f2(a: Any | None, b: str | None) -> None:
3282+ if None is not a == b:
3283+ reveal_type(a) # N: Revealed type is "Any"
3284+ reveal_type(b) # N: Revealed type is "builtins.str | None"
3285+
3286+ if (None is not a) and (a == b):
3287+ reveal_type(a) # N: Revealed type is "Any"
3288+ reveal_type(b) # N: Revealed type is "builtins.str | None"
3289+
3290+ def f3(a: str | None, b: Any | None) -> None:
3291+ if None is not a == b:
3292+ reveal_type(a) # N: Revealed type is "builtins.str"
3293+ reveal_type(b) # N: Revealed type is "Any | builtins.str | None"
3294+
3295+ if (None is not a) and (a == b):
3296+ reveal_type(a) # N: Revealed type is "builtins.str"
3297+ reveal_type(b) # N: Revealed type is "Any | builtins.str"
3298+ [builtins fixtures/primitives.pyi]
3299+
32673300[case testNarrowTypeObject]
32683301# flags: --strict-equality --warn-unreachable
32693302from typing import Any
0 commit comments