Skip to content

Commit

Permalink
fixing defaults for function interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed May 29, 2024
1 parent c97e489 commit caee1bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nipype2pydra/interface/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def pydra_fld_input(self, field, nm):

pos = pydra_metadata.get("position", None)

if pydra_default is not None and not pydra_metadata.get("mandatory", None):
if pydra_default is not None: # and not pydra_metadata.get("mandatory", None):
return (pydra_type, pydra_default, pydra_metadata), pos
else:
return (pydra_type, pydra_metadata), pos
Expand Down
9 changes: 8 additions & 1 deletion nipype2pydra/interface/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ def types_to_names(spec_fields):
spec_str += ", ".join(f"'{n}': {t}" for n, t, _ in output_fields_str)
spec_str += "}})\n"
spec_str += f"def {self.task_name}("
spec_str += ", ".join(f"{i[0]}: {i[1]}" for i in input_fields_str)
spec_str += ", ".join(
(
f"{i[0]}: {i[1]} = {i[2]!r}"
if len(i) == 4
else f"{i[0]}: {i[1]} = attrs.NOTHING"
)
for i in input_fields_str
)
spec_str += ")"
if output_type_names:
spec_str += "-> "
Expand Down

0 comments on commit caee1bc

Please sign in to comment.