File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 9
9
import weakref
10
10
from abc import ABC , abstractmethod
11
11
from collections import OrderedDict
12
- from dataclasses import dataclass , field
12
+ from dataclasses import dataclass , field , fields , is_dataclass
13
13
from typing import (
14
14
Any ,
15
15
Callable ,
@@ -648,16 +648,24 @@ def _convert_params(
648
648
kw_args = {}
649
649
args = []
650
650
params_added = False
651
- rest = set (converted_params .__dict__ .keys ())
651
+
652
+ field_names = (
653
+ [f .name for f in fields (converted_params )]
654
+ if is_dataclass (converted_params )
655
+ else list (converted_params .__dict__ .keys ())
656
+ )
657
+
658
+ rest = set (field_names )
652
659
if isinstance (params , dict ):
653
660
rest = set .union (rest , params .keys ())
654
661
655
662
for v in signature .parameters .values ():
656
- if v .name in converted_params . __dict__ :
663
+ if v .name in field_names :
657
664
if v .kind == inspect .Parameter .POSITIONAL_ONLY :
658
665
args .append (getattr (converted_params , v .name ))
659
666
else :
660
667
kw_args [v .name ] = getattr (converted_params , v .name )
668
+
661
669
rest .remove (v .name )
662
670
elif v .name == "params" :
663
671
if v .kind == inspect .Parameter .POSITIONAL_ONLY :
You can’t perform that action at this time.
0 commit comments