@@ -2440,34 +2440,28 @@ def check_argument_types(
24402440 # the suffices to the tuple, e.g. a single actual like
24412441 # Tuple[Unpack[Ts], int]
24422442 expanded_tuple = False
2443+ actual_kinds = [arg_kinds [a ] for a in actuals ]
24432444 if len (actuals ) > 1 :
2444- first_actual_arg_type = get_proper_type (arg_types [actuals [0 ]])
2445+ p_actual_type = get_proper_type (arg_types [actuals [0 ]])
24452446 if (
2446- isinstance (first_actual_arg_type , TupleType )
2447- and len (first_actual_arg_type .items ) == 1
2448- and isinstance (first_actual_arg_type .items [0 ], UnpackType )
2447+ isinstance (p_actual_type , TupleType )
2448+ and len (p_actual_type .items ) == 1
2449+ and isinstance (p_actual_type .items [0 ], UnpackType )
2450+ and actual_kinds == [nodes .ARG_STAR ] + [nodes .ARG_POS ] * (len (actuals ) - 1 )
24492451 ):
2450- # TODO: use walrus operator
2451- actual_types = [first_actual_arg_type .items [0 ]] + [
2452- arg_types [a ] for a in actuals [1 :]
2453- ]
2454- actual_kinds = [nodes .ARG_STAR ] + [nodes .ARG_POS ] * (len (actuals ) - 1 )
2455-
2456- # If we got here, the callee was previously inferred to have a suffix.
2457- assert isinstance (orig_callee_arg_type , UnpackType )
2458- assert isinstance (orig_callee_arg_type .type , ProperType ) and isinstance (
2459- orig_callee_arg_type .type , TupleType
2460- )
2461- assert orig_callee_arg_type .type .items
2462- callee_arg_types = orig_callee_arg_type .type .items
2463- callee_arg_kinds = [nodes .ARG_STAR ] + [nodes .ARG_POS ] * (
2464- len (orig_callee_arg_type .type .items ) - 1
2465- )
2466- expanded_tuple = True
2452+ actual_types = [p_actual_type .items [0 ]] + [arg_types [a ] for a in actuals [1 :]]
2453+ if isinstance (orig_callee_arg_type , UnpackType ):
2454+ p_callee_type = get_proper_type (orig_callee_arg_type .type )
2455+ if isinstance (p_callee_type , TupleType ):
2456+ assert p_callee_type .items
2457+ callee_arg_types = p_callee_type .items
2458+ callee_arg_kinds = [nodes .ARG_STAR ] + [nodes .ARG_POS ] * (
2459+ len (p_callee_type .items ) - 1
2460+ )
2461+ expanded_tuple = True
24672462
24682463 if not expanded_tuple :
24692464 actual_types = [arg_types [a ] for a in actuals ]
2470- actual_kinds = [arg_kinds [a ] for a in actuals ]
24712465 if isinstance (orig_callee_arg_type , UnpackType ):
24722466 unpacked_type = get_proper_type (orig_callee_arg_type .type )
24732467 if isinstance (unpacked_type , TupleType ):
0 commit comments