File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -4195,11 +4195,17 @@ def check_op(
41954195 # We don't do the same for the base expression because it could lead to weird
41964196 # type inference errors -- e.g. see 'testOperatorDoubleUnionSum'.
41974197 # TODO: Can we use `type_overrides_set()` here?
4198- right_variants = [
4199- (item , TempNode (item , context = context ))
4200- for item in self ._union_items_from_typevar (right_type )
4201- ]
4202- right_type = get_proper_type (right_type )
4198+ right_variants : list [tuple [Type , Expression ]]
4199+ p_right = get_proper_type (right_type )
4200+ if isinstance (p_right , (UnionType , TypeVarType )):
4201+ right_variants = [
4202+ (item , TempNode (item , context = context ))
4203+ for item in self ._union_items_from_typevar (right_type )
4204+ ]
4205+ else :
4206+ # Preserve argument identity if we do not intend to modify it
4207+ right_variants = [(right_type , arg )]
4208+ right_type = p_right
42034209
42044210 all_results = []
42054211 all_inferred = []
You can’t perform that action at this time.
0 commit comments