Skip to content

Commit 5170a26

Browse files
committed
bug fixed doctests gen
1 parent 9435582 commit 5170a26

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

nipype2pydra/task/base.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,19 @@ def create_doctests(self, input_fields, nonstd_types):
914914
if is_fileset(tp):
915915
val = f"{tp.__name__}.mock({val})"
916916
elif ty.get_origin(tp) is list and is_fileset(ty.get_args(tp)[0]):
917-
val = (
918-
"["
919-
+ ", ".join(
920-
f'{ty.get_args(tp)[0].__name__}.mock("{v}")'
921-
for v in eval(val)
917+
try:
918+
val = eval(val)
919+
except Exception:
920+
pass
921+
else:
922+
val = (
923+
"["
924+
+ ", ".join(
925+
f'{ty.get_args(tp)[0].__name__}.mock("{v}")'
926+
for v in val
927+
)
928+
+ "]"
922929
)
923-
+ "]"
924-
)
925930
elif tp is str and not (val.startswith("'") or val.startswith('"')):
926931
val = f'"{val}"'
927932
if val is None and is_fileset(tp):

0 commit comments

Comments
 (0)