@@ -2440,34 +2440,28 @@ def check_argument_types(
2440
2440
# the suffices to the tuple, e.g. a single actual like
2441
2441
# Tuple[Unpack[Ts], int]
2442
2442
expanded_tuple = False
2443
<
8000
code class="diff-text syntax-highlighted-line addition">+ actual_kinds = [arg_kinds [a ] for a in actuals ]
2443
2444
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 ]])
2445
2446
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 )
2449
2451
):
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
2467
2462
2468
2463
if not expanded_tuple :
2469
2464
actual_types = [arg_types [a ] for a in actuals ]
2470
- actual_kinds = [arg_kinds [a ] for a in actuals ]
2471
2465
if isinstance (orig_callee_arg_type , UnpackType ):
2472
2466
unpacked_type = get_proper_type (orig_callee_arg_type .type )
2473
2467
if isinstance (unpacked_type , TupleType ):
0 commit comments