@@ -2357,7 +2357,8 @@ def check_argument_count(
23572357
23582358 # Check for too many or few values for formals.
23592359 for i , kind in enumerate (callee .arg_kinds ):
2360- if kind .is_required () and not formal_to_actual [i ] and not is_unexpected_arg_error :
2360+ mapped_args = formal_to_actual [i ]
2361+ if kind .is_required () and not mapped_args and not is_unexpected_arg_error :
23612362 # No actual for a mandatory formal
23622363 if kind .is_positional ():
23632364 self .msg .too_few_arguments (callee , context , actual_names )
@@ -2368,28 +2369,32 @@ def check_argument_count(
23682369 self .msg .missing_named_argument (callee , context , argname )
23692370 ok = False
23702371 elif not kind .is_star () and is_duplicate_mapping (
2371- formal_to_actual [ i ] , actual_types , actual_kinds
2372+ mapped_args , actual_types , actual_kinds
23722373 ):
23732374 if self .chk .in_checked_function () or isinstance (
2374- get_proper_type (actual_types [formal_to_actual [ i ] [0 ]]), TupleType
2375+ get_proper_type (actual_types [mapped_args [0 ]]), TupleType
23752376 ):
23762377 self .msg .duplicate_argument_value (callee , i , context )
23772378 ok = False
23782379 elif (
23792380 kind .is_named ()
2380- and formal_to_actual [ i ]
2381- and actual_kinds [formal_to_actual [ i ] [0 ]] not in [nodes .ARG_NAMED , nodes .ARG_STAR2 ]
2381+ and mapped_args
2382+ and actual_kinds [mapped_args [0 ]] not in [nodes .ARG_NAMED , nodes .ARG_STAR2 ]
23822383 ):
23832384 # Positional argument when expecting a keyword argument.
23842385 self .msg .too_many_positional_arguments (callee , context )
23852386 ok = False
2386- elif (
2387- callee .param_spec () is not None
2388- and not formal_to_actual [i ]
2389- and callee .special_sig != "partial"
2390- ):
2391- self .msg .too_few_arguments (callee , context , actual_names )
2392- ok = False
2387+ elif callee .param_spec () is not None :
2388+ if not mapped_args and callee .special_sig != "partial" :
2389+ self .msg .too_few_arguments (callee , context , actual_names )
2390+ ok = False
2391+ elif len (mapped_args ) > 1 :
2392+ if actual_kinds [mapped_args [0 ]] == nodes .ARG_STAR :
2393+ self .msg .fail ("ParamSpec.args should only be passed once" , context )
2394+ ok = False
2395+ if actual_kinds [mapped_args [0 ]] == nodes .ARG_STAR2 :
2396+ self .msg .fail ("ParamSpec.kwargs should only be passed once" , context )
2397+ ok = False
23932398 return ok
23942399
23952400 def check_for_extra_actual_arguments (
0 commit comments