@@ -2495,6 +2495,19 @@ def missing_classvar_callable_note(
24952495 context ,
24962496 )
24972497
2498+ def check_var_args_kwargs (
2499+ self , arg_types : list [Type ], arg_kinds : list [ArgKind ], context : Context
2500+ ):
2501+ for arg_type , arg_kind in zip (arg_types , arg_kinds ):
2502+ arg_type = get_proper_type (arg_type )
2503+ if arg_kind == nodes .ARG_STAR and not self .is_valid_var_arg (arg_type ):
2504+ self .msg .invalid_var_arg (arg_type , context )
2505+ if arg_kind == nodes .ARG_STAR2 and not self .is_valid_keyword_var_arg (arg_type ):
2506+ is_mapping = is_subtype (
2507+ arg_type , self .chk .named_type ("_typeshed.SupportsKeysAndGetItem" )
2508+ )
2509+ self .msg .invalid_keyword_var_arg (arg_type , is_mapping , context )
2510+
24982511 def check_argument_types (
24992512 self ,
25002513 arg_types : list [Type ],
@@ -2512,15 +2525,7 @@ def check_argument_types(
25122525
25132526 The check_call docstring describes some of the arguments.
25142527 """
2515- for arg_type , arg_kind in zip (arg_types , arg_kinds ):
2516- arg_type = get_proper_type (arg_type )
2517- if arg_kind == nodes .ARG_STAR and not self .is_valid_var_arg (arg_type ):
2518- self .msg .invalid_var_arg (arg_type , context )
2519- if arg_kind == nodes .ARG_STAR2 and not self .is_valid_keyword_var_arg (arg_type ):
2520- is_mapping = is_subtype (
2521- arg_type , self .chk .named_type ("_typeshed.SupportsKeysAndGetItem" )
2522- )
2523- self .msg .invalid_keyword_var_arg (arg_type , is_mapping , context )
2528+ self .check_var_args_kwargs (arg_types , arg_kinds , context )
25242529
25252530 check_arg = check_arg or self .check_arg
25262531 # Keep track of consumed tuple *arg items.
@@ -3301,15 +3306,7 @@ def check_any_type_call(
33013306 self , args : list [Expression ], arg_kinds : list [ArgKind ], callee : Type , context : Context
33023307 ) -> tuple [Type , Type ]:
33033308 arg_types = self .infer_arg_types_in_empty_context (args )
3304- for arg_type , arg_kind in zip (arg_types , arg_kinds ):
3305- arg_type = get_proper_type (arg_type )
3306- if arg_kind == nodes .ARG_STAR and not self .is_valid_var_arg (arg_type ):
3307- self .msg .invalid_var_arg (arg_type , context )
3308- if arg_kind == nodes .ARG_STAR2 and not self .is_valid_keyword_var_arg (arg_type ):
3309- is_mapping = is_subtype (
3310- arg_type , self .chk .named_type ("_typeshed.SupportsKeysAndGetItem" )
3311- )
3312- self .msg .invalid_keyword_var_arg (arg_type , is_mapping , context )
3309+ self .check_var_args_kwargs (arg_types , arg_kinds , context )
33133310
33143311 callee = get_proper_type (callee )
33153312 if isinstance (callee , AnyType ):
0 commit comments