@@ -533,26 +533,40 @@ def verify_args(func, iterdata, extra_args):
533533 non_verify_args = ['ibm_cos' , 'storage' , 'id' , 'rabbitmq' ]
534534 func_sig = inspect .signature (func )
535535
536- new_parameters = list ()
537- for param in func_sig . parameters :
538- if param not in non_verify_args :
539- new_parameters . append ( func_sig . parameters [ param ])
540-
536+ new_parameters = [
537+ param
538+ for name , param in func_sig . parameters . items ()
539+ if name not in non_verify_args
540+ ]
541541 new_func_sig = func_sig .replace (parameters = new_parameters )
542542
543- new_data = list ()
543+ # Detect presence of **kwargs (with any name)
544+ has_var_keyword = any (
545+ p .kind == inspect .Parameter .VAR_KEYWORD
546+ for p in new_func_sig .parameters .values ()
547+ )
548+
549+ new_data = []
550+
544551 for elem in data :
545552 if isinstance (elem , dict ):
546- if set (list (new_func_sig .parameters .keys ())) <= set (elem ):
553+ # If the function accepts **kwargs (any name), we cannot reliably
554+ # enforce exact param name matching here, and we *want* to allow
555+ # passing through arbitrary dicts (e.g., original function args)
556+ # even when a decorator wrapper has **kwargs, etc.
557+ if has_var_keyword :
558+ new_data .append (elem )
559+ elif set (expected_keys := list (new_func_sig .parameters )) <= set (elem ):
560+ # No **kwargs: enforce that the dict contains at least all
561+ # required user parameters (excluding reserved ones).
547562 new_data .append (elem )
548563 else :
549- raise ValueError ("Check the args names in the data. "
550- "You provided these args: {}, and "
551- "the args must be: {}"
552- .format (list (elem .keys ()),
553- list (new_func_sig .parameters .keys ())))
564+ raise ValueError (
565+ "Check the args names in the data. You provided these args: " ,
566+ f"{ list (elem )} , and the args must be: { expected_keys } " ,
567+ )
554568 elif isinstance (elem , tuple ):
555- new_elem = dict (new_func_sig .bind (* list ( elem ) ).arguments )
569+ new_elem = dict (new_func_sig .bind (* elem ).arguments )
556570 new_data .append (new_elem )
557571 else :
558572 # single value (list, string, integer, dict, etc)
0 commit comments