@@ -1032,24 +1032,24 @@ def check_callable_call(self,
10321032 callee = self .infer_function_type_arguments (
10331033 callee , args , arg_kinds , formal_to_actual , context )
10341034 if need_refresh :
1035- # Argument kinds etc. may have changed; recalculate actual-to-formal map
1035+ # Argument kinds etc. may have changed due to
1036+ # ParamSpec variables being replaced with an arbitrary
1037+ # number of arguments; recalculate actual-to-formal map
10361038 formal_to_actual = map_actuals_to_formals (
10371039 arg_kinds , arg_names ,
10381040 callee .arg_kinds , callee .arg_names ,
10391041 lambda i : self .accept (args [i ]))
10401042
10411043 param_spec = callee .param_spec ()
10421044 if param_spec is not None and arg_kinds == [ARG_STAR , ARG_STAR2 ]:
1043- arg1 = get_proper_type (self .accept (args [0 ]))
1044- arg2 = get_proper_type (self .accept (args [1 ]))
1045- if (is_named_instance (arg1 , 'builtins.tuple' )
1046- and is_named_instance (arg2 , 'builtins.dict' )):
1047- assert isinstance (arg1 , Instance )
1048- assert isinstance (arg2 , Instance )
1049- if (isinstance (arg1 .args [0 ], ParamSpecType )
1050- and isinstance (arg2 .args [1 ], ParamSpecType )):
1051- # TODO: Check ParamSpec ids and flavors
1052- return callee .ret_type , callee
1045+ arg1 = self .accept (args [0 ])
1046+ arg2 = self .accept (args [1 ])
1047+ if (isinstance (arg1 , ParamSpecType )
1048+ and isinstance (arg2 , ParamSpecType )
1049+ and arg1 .flavor == ParamSpecFlavor .ARGS
1050+ and arg2 .flavor == ParamSpecFlavor .KWARGS
1051+ and arg1 .id == arg2 .id == param_spec .id ):
1052+ return callee .ret_type , callee
10531053
10541054 arg_types = self .infer_arg_types_in_context (
10551055 callee , args , arg_kinds , formal_to_actual )
@@ -4003,7 +4003,7 @@ def is_valid_var_arg(self, typ: Type) -> bool:
40034003 is_subtype (typ , self .chk .named_generic_type ('typing.Iterable' ,
40044004 [AnyType (TypeOfAny .special_form )])) or
40054005 isinstance (typ , AnyType ) or
4006- ( isinstance (typ , ParamSpecType ) and typ . flavor == ParamSpecFlavor . ARGS ))
4006+ isinstance (typ , ParamSpecType ))
40074007
40084008 def is_valid_keyword_var_arg (self , typ : Type ) -> bool :
40094009 """Is a type valid as a **kwargs argument?"""
@@ -4012,7 +4012,7 @@ def is_valid_keyword_var_arg(self, typ: Type) -> bool:
40124012 [self .named_type ('builtins.str' ), AnyType (TypeOfAny .special_form )])) or
40134013 is_subtype (typ , self .chk .named_generic_type ('typing.Mapping' ,
40144014 [UninhabitedType (), UninhabitedType ()])) or
4015- ( isinstance (typ , ParamSpecType ) and typ . flavor == ParamSpecFlavor . KWARGS )
4015+ isinstance (typ , ParamSpecType )
40164016 )
40174017 if self .chk .options .python_version [0 ] < 3 :
40184018 ret = ret or is_subtype (typ , self .chk .named_generic_type ('typing.Mapping' ,
0 commit comments