Skip to content

Commit 9fe7ccd

Browse files
committed
replace getfullargspec by signature
1 parent f756b71 commit 9fe7ccd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

nipype/interfaces/dipy/base.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ def _gen_filename(self, name, ext=None):
9090
return out_prefix + "_" + name + ext
9191

9292

93+
def get_default_args(func):
94+
"""Return optional arguments of a function.
95+
96+
Parameters
97+
----------
98+
func: callable
99+
100+
Returns
101+
-------
102+
dict
103+
"""
104+
signature = inspect.signature(func)
105+
return {k: v.default for k, v in signature.parameters.items()
106+
if v.default is not inspect.Parameter.empty
107+
}
108+
109+
93110
def convert_to_traits_type(dipy_type, is_file=False):
94111
"""Convert DIPY type to Traits type."""
95112
dipy_type = dipy_type.lower()
@@ -189,7 +206,7 @@ def dipy_to_nipype_interface(cls_name, dipy_flow, BaseClass=DipyBaseInterface):
189206
parser = IntrospectiveArgumentParser()
190207
flow = dipy_flow()
191208
parser.add_workflow(flow)
192-
default_values = inspect.getfullargspec(flow.run).defaults
209+
default_values = list(get_default_args(flow.run).values())
193210
optional_params = [
194211
args + (val,) for args, val in zip(parser.optional_parameters, default_values)
195212
]

0 commit comments

Comments
 (0)