Skip to content

Commit 369524a

Browse files
committed
fix typing converting issue
1 parent f960b93 commit 369524a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nipype2pydra/task.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
import typing as ty
44
from types import ModuleType
5+
import re
56
import inspect
67
import black
78
import traits
@@ -329,8 +330,17 @@ def types_to_names(spec_fields):
329330
spec_str += f" output_spec = {self.task_name}_output_spec\n"
330331
spec_str += f" executable='{self.nipype_interface._cmd}'\n"
331332

332-
for tp_repl in self.TYPE_REPLACE:
333-
spec_str = spec_str.replace(*tp_repl)
333+
# for tp_repl in self.TYPE_REPLACE:
334+
# spec_str = spec_str.replace(*tp_repl)
335+
336+
# apply each replacement in TYPE_REPLACE
337+
for old, new in self.TYPE_REPLACE:
338+
# add a comma and newline to the old string, to match only at the end of lines
339+
old += ",\n"
340+
# add a comma and newline to the new string, to replace with
341+
new += ",\n"
342+
# use re.sub to replace old with new, in spec_str
343+
spec_str = re.sub(old, new, spec_str)
334344

335345
spec_str_black = black.format_file_contents(
336346
spec_str, fast=False, mode=black.FileMode()

0 commit comments

Comments
 (0)