File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6812,13 +6812,20 @@ def narrow_type_by_identity_equality(
68126812 # We patch this here because it is desirable to widen to any for cases like
68136813 # isinstance(x, (y: Any))
68146814 continue
6815+
6816+ arg_type = self .lookup_type (expr_in_type_expr )
6817+ if_type , else_type = self .conditional_types_with_intersection (
6818+ arg_type , [current_type_range ], expr_in_type_expr
6819+ )
6820+ if if_type is not None and (
6821+ not current_type_range .is_upper_bound
6822+ and not is_equivalent (if_type , current_type_range .item )
6823+ ):
6824+ # type(x) and x.__class__ checks must exact match
6825+ if_type = UninhabitedType ()
6826+
68156827 if_map , else_map = conditional_types_to_typemaps (
6816- expr_in_type_expr ,
6817- * self .conditional_types_with_intersection (
6818- self .lookup_type (expr_in_type_expr ),
6819- [current_type_range ],
6820- expr_in_type_expr ,
6821- ),
6828+ expr_in_type_expr , if_type , else_type
68226829 )
68236830
68246831 is_final = (
Original file line number Diff line number Diff line change @@ -3152,7 +3152,7 @@ else:
31523152 reveal_type(y) # N: Revealed type is "builtins.str"
31533153[builtins fixtures/isinstance.pyi]
31543154
3155- [case testTypeEqualsCheckUsingIsNonOverlappingChild-xfail ]
3155+ [case testTypeEqualsCheckUsingIsNonOverlappingChild]
31563156# flags: --strict-equality --warn-unreachable
31573157from typing import Union
31583158
You can’t perform that action at this time.
0 commit comments