@@ -2481,6 +2481,17 @@ def check_argument_types(
2481
2481
check_arg = check_arg or self .check_arg
2482
2482
# Keep track of consumed tuple *arg items.
2483
2483
mapper = ArgTypeExpander (self .argument_infer_context ())
2484
+
2485
+ for arg_type , arg_kind in zip (arg_types , arg_kinds ):
2486
+ arg_type = get_proper_type (arg_type )
2487
+ if arg_kind == nodes .ARG_STAR and not self .is_valid_var_arg (arg_type ):
2488
+ self .msg .invalid_var_arg (arg_type , context )
2489
+ if arg_kind == nodes .ARG_STAR2 and not self .is_valid_keyword_var_arg (arg_type ):
2490
+ is_mapping = is_subtype (
2491
+ arg_type , self .chk .named_type ("_typeshed.SupportsKeysAndGetItem" )
2492
+ )
2493
+ self .msg .invalid_keyword_var_arg (arg_type , is_mapping , context )
2494
+
2484
2495
for i , actuals in enumerate (formal_to_actual ):
2485
2496
orig_callee_arg_type = get_proper_type (callee .arg_types [i ])
2486
2497
@@ -2573,15 +2584,6 @@ def check_argument_types(
2573
2584
if actual_type is None :
2574
2585
continue # Some kind of error was already reported.
2575
2586
# Check that a *arg is valid as varargs.
2576
- if actual_kind == nodes .ARG_STAR and not self .is_valid_var_arg (actual_type ):
2577
- self .msg .invalid_var_arg (actual_type , context )
2578
- if actual_kind == nodes .ARG_STAR2 and not self .is_valid_keyword_var_arg (
2579
- actual_type
2580
- ):
2581
- is_mapping = is_subtype (
2582
- actual_type , self .chk .named_type ("_typeshed.SupportsKeysAndGetItem" )
2583
- )
2584
- self .msg .invalid_keyword_var_arg (actual_type , is_mapping , context )
2585
2587
expanded_actual = mapper .expand_actual_type (
2586
2588
actual_type ,
2587
2589
actual_kind ,
0 commit comments