Skip to content

Commit a1d6301

Browse files
committed
fix: cover one more edge case (nipype.interfaces.base.DictStrStr)
1 parent b819505 commit a1d6301

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

nipype/interfaces/base/tests/test_traits_extension.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class _test_spec(nib.TraitedSpec):
2020
i = nib.traits.Either(nib.File, nib.traits.Tuple(nib.File, nib.traits.Int))
2121
j = nib.traits.Either(nib.File, nib.traits.Tuple(nib.File, nib.traits.Int),
2222
nib.traits.Dict(nib.Str, nib.File()))
23+
k = nib.DictStrStr
2324

2425

2526
def test_rebase_resolve_path_traits():
@@ -300,3 +301,13 @@ def test_rebase_resolve_path_traits():
300301

301302
# Idempotence
302303
assert resolve_path_traits(spec.trait('j'), j, '/some/path') == j
304+
305+
v = {'path': '/some/path/f1.txt'}
306+
k = rebase_path_traits(spec.trait('k'), v, '/some/path')
307+
assert k == v
308+
309+
# Idempotence
310+
assert rebase_path_traits(spec.trait('k'), k, '/some/path') == k
311+
312+
k = resolve_path_traits(spec.trait('k'), k, '/some/path')
313+
assert k == v

nipype/interfaces/base/traits_extension.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,12 @@ def _recurse_on_path_traits(func, thistrait, value, cwd):
520520
return value
521521

522522
for subtrait in thistrait.handler.handlers:
523-
value = _recurse_on_path_traits(func, subtrait(), value, cwd)
523+
try:
524+
sb_instance = subtrait()
525+
except TypeError:
526+
return value
527+
else:
528+
value = _recurse_on_path_traits(func, sb_instance, value, cwd)
524529

525530
return value
526531

0 commit comments

Comments
 (0)