Skip to content

Commit b0c80d7

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

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

nipype/interfaces/base/tests/test_traits_extension.py

Lines changed: 11 additions & 1 deletion
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():
@@ -209,7 +210,6 @@ def test_rebase_resolve_path_traits():
209210
# Idempotence
210211
assert resolve_path_traits(spec.trait('g'), g, '/some') == g
211212

212-
v = v
213213
g = rebase_path_traits(spec.trait('g'), v, '/some/path')
214214
assert g == v # You dont want this one to be a Path
215215

@@ -300,3 +300,13 @@ def test_rebase_resolve_path_traits():
300300

301301
# Idempotence
302302
assert resolve_path_traits(spec.trait('j'), j, '/some/path') == j
303+
304+
v = {'path': '/some/path/f1.txt'}
305+
k = rebase_path_traits(spec.trait('k'), v, '/some/path')
306+
assert k == v
307+
308+
# Idempotence
309+
assert rebase_path_traits(spec.trait('k'), k, '/some/path') == k
310+
311+
k = resolve_path_traits(spec.trait('k'), k, '/some/path')
312+
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)