Skip to content

Commit 7d1b5fd

Browse files
committed
FIX: Replace deprecated HasTraits.get with trait_get
Deprecation mark: https://github.com/enthought/traits/blob/a99b3f64d50c5f7f28ffc01bf69419b061f9e976/traits/has_traits.py#L1481 Fixes the following deprecation warning: ``` nipype/nipype/interfaces/base/specs.py:160: DeprecationWarning: use "HasTraits.trait_get" instead out = super(BaseTraitedSpec, self).get(**kwargs) ``` This warning has started to appear recently, traits must have gotten a major update.
1 parent dc09e00 commit 7d1b5fd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

nipype/interfaces/base/specs.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from builtins import str, bytes
1919
from packaging.version import Version
2020

21-
from ...utils.misc import is_container
2221
from ...utils.filemanip import md5, hash_infile, hash_timestamp, to_str
2322
from .traits_extension import (
2423
traits,
@@ -157,7 +156,10 @@ def get(self, **kwargs):
157156
Augments the trait get function to return a dictionary without
158157
notification handles
159158
"""
160-
out = super(BaseTraitedSpec, self).get(**kwargs)
159+
try:
160+
out = super(BaseTraitedSpec, self).trait_get(**kwargs)
161+
except AttributeError: # deprecated old get
162+
out = super(BaseTraitedSpec, self).get(**kwargs)
161163
out = self._clean_container(out, Undefined)
162164
return out
163165

@@ -183,8 +185,8 @@ def _clean_container(self, objekt, undefinedval=None, skipundefined=False):
183185
else:
184186
if not skipundefined:
185187
out[key] = undefinedval
186-
elif (isinstance(objekt, TraitListObject) or isinstance(objekt, list)
187-
or isinstance(objekt, tuple)):
188+
elif (isinstance(objekt, TraitListObject) or isinstance(objekt, list) or
189+
isinstance(objekt, tuple)):
188190
out = []
189191
for val in objekt:
190192
if isdefined(val):
@@ -241,8 +243,8 @@ def get_hashval(self, hash_method=None):
241243
# skip undefined traits and traits with nohash=True
242244
continue
243245

244-
hash_files = (not self.has_metadata(name, "hash_files", False)
245-
and not self.has_metadata(name, "name_source"))
246+
hash_files = (not self.has_metadata(name, "hash_files", False) and
247+
not self.has_metadata(name, "name_source"))
246248
list_nofilename.append((name,
247249
self._get_sorteddict(
248250
val,
@@ -286,8 +288,8 @@ def _get_sorteddict(self,
286288
else:
287289
out = None
288290
if isdefined(objekt):
289-
if (hash_files and isinstance(objekt, (str, bytes))
290-
and os.path.isfile(objekt)):
291+
if (hash_files and isinstance(objekt, (str, bytes)) and
292+
os.path.isfile(objekt)):
291293
if hash_method is None:
292294
hash_method = config.get('execution', 'hash_method')
293295

0 commit comments

Comments
 (0)