@@ -6726,37 +6726,37 @@ def narrow_type_by_identity_equality(
67266726 else_map = {} # this is the big difference compared to the above
67276727 partial_type_maps .append ((if_map , else_map ))
67286728
6729- exprs_in_type_calls = []
67306729 for i in expr_indices :
6731- expr = operands [i ]
6732- if isinstance (expr , CallExpr ) and is_type_call (expr ):
6733- exprs_in_type_calls .append (expr .args [0 ])
6734-
6735- if exprs_in_type_calls :
6736- for expr_in_type_call in exprs_in_type_calls :
6737- for i in expr_indices :
6738- expr = operands [i ]
6739- if isinstance (expr , CallExpr ) and is_type_call (expr ):
6740- continue
6741-
6742- current_type_range = self .get_isinstance_type (expr )
6743- if_map , else_map = conditional_types_to_typemaps (
6744- expr_in_type_call ,
6745- * self .conditional_types_with_intersection (
6746- self .lookup_type (expr_in_type_call ),
6747- current_type_range ,
6748- expr_in_type_call ,
6749- ),
6750- )
6730+ type_expr = operands [i ]
6731+ if (
6732+ isinstance (type_expr , CallExpr )
6733+ and refers_to_fullname (type_expr .callee , "builtins.type" )
6734+ and len (type_expr .args ) == 1
6735+ ):
6736+ expr_in_type_expr = type_expr .args [0 ]
6737+ else :
6738+ continue
6739+ for j in expr_indices :
6740+ if i == j :
6741+ continue
6742+ expr = operands [j ]
6743+
6744+ current_type_range = self .get_isinstance_type (expr )
6745+ if_map , else_map = conditional_types_to_typemaps (
6746+ expr_in_type_expr ,
6747+ * self .conditional_types_with_intersection (
6748+ self .lookup_type (expr_in_type_expr ), current_type_range , expr_in_type_expr
6749+ ),
6750+ )
67516751
6752- is_final = (
6753- expr .node .is_final
6754- if isinstance (expr , RefExpr ) and isinstance (expr .node , TypeInfo )
6755- else False
6756- )
6757- if not is_final :
6758- else_map = {}
6759- partial_type_maps .append ((if_map , else_map ))
6752+ is_final = (
6753+ expr .node .is_final
6754+ if isinstance (expr , RefExpr ) and isinstance (expr .node , TypeInfo )
6755+ else False
6756+ )
6757+ if not is_final :
6758+ else_map = {}
6759+ partial_type_maps .append ((if_map , else_map ))
67606760
67616761 # We will not have duplicate entries in our type maps if we only have two operands,
67626762 # so we can skip running meets on the intersections
@@ -8562,11 +8562,6 @@ def has_custom_eq_checks(t: Type) -> bool:
85628562 )
85638563
85648564
8565- def is_type_call (expr : CallExpr ) -> bool :
8566- """Is expr a call to type with one argument?"""
8567- return refers_to_fullname (expr .callee , "builtins.type" ) and len (expr .args ) == 1
8568-
8569-
85708565def convert_to_typetype (type_map : TypeMap ) -> TypeMap :
85718566 converted_type_map : dict [Expression , Type ] = {}
85728567 if type_map is None :
0 commit comments