@@ -3129,6 +3129,7 @@ def combine_function_signatures(self, types: list[ProperType]) -> AnyType | Call
31293129 assert types , "Trying to merge no callables"
31303130 if not all (isinstance (c , CallableType ) for c in types ):
31313131 return AnyType (TypeOfAny .special_form )
3132+
31323133 callables = cast ("list[CallableType]" , types )
31333134 if len (callables ) == 1 :
31343135 return callables [0 ]
@@ -3146,11 +3147,10 @@ def combine_function_signatures(self, types: list[ProperType]) -> AnyType | Call
31463147 # confusing and ought to be re-written anyways.)
31473148 callables , variables = merge_typevars_in_callables_by_name (callables )
31483149
3149- new_args : list [list [Type ]] = [[] for _ in range (len (callables [0 ].arg_types ))]
3150- new_kinds = list (callables [0 ].arg_kinds )
3151- new_returns : list [Type ] = []
3152-
3150+ new_args : list [list [Type ]] = [[] for _ in callables [0 ].arg_types ]
3151+ new_kinds , new_returns = list (callables [0 ].arg_kinds ), []
31533152 too_complex = False
3153+
31543154 for target in callables :
31553155 # We fall back to Callable[..., Union[<returns>]] if the functions do not have
31563156 # the exact same signature. The only exception is if one arg is optional and
@@ -3160,18 +3160,14 @@ def combine_function_signatures(self, types: list[ProperType]) -> AnyType | Call
31603160 if len (new_kinds ) != len (target .arg_kinds ):
31613161 too_complex = True
31623162 break
3163- for i , (new_kind , target_kind ) in enumerate (zip (new_kinds , target .arg_kinds )):
3164- if new_kind == target_kind :
3165- continue
3166- elif new_kind .is_positional () and target_kind .is_positional ():
3163+ for i , (k1 , k2 ) in enumerate (zip (new_kinds , target .arg_kinds )):
3164+ if k1 == k2 : continue
3165+ if k1 .is_positional () and k2 .is_positional ():
31673166 new_kinds [i ] = ARG_POS
31683167 else :
31693168 too_complex = True
31703169 break
3171-
3172- if too_complex :
3173- break # outer loop
3174-
3170+ if too_complex : break
31753171 for i , arg in enumerate (target .arg_types ):
31763172 new_args [i ].append (arg )
31773173 new_returns .append (target .ret_type )
@@ -3188,13 +3184,8 @@ def combine_function_signatures(self, types: list[ProperType]) -> AnyType | Call
31883184 implicit = True ,
31893185 )
31903186
3191- final_args = []
3192- for args_list in new_args :
3193- new_type = make_simplified_union (args_list )
3194- final_args .append (new_type )
3195-
31963187 return callables [0 ].copy_modified (
3197- arg_types = final_args ,
3188+ arg_types = [ make_simplified_union ( args ) for args in new_args ] ,
31983189 arg_kinds = new_kinds ,
31993190 ret_type = union_return ,
32003191 variables = variables ,
0 commit comments