diff --git a/python/lsst/pex/config/configDictField.py b/python/lsst/pex/config/configDictField.py index ef675b1..fd187af 100644 --- a/python/lsst/pex/config/configDictField.py +++ b/python/lsst/pex/config/configDictField.py @@ -59,7 +59,7 @@ def __setitem__(self, k, x, at=None, label="setitem", setHistory=True): # validate itemtype dtype = self._field.itemtype - if type(x) != self._field.itemtype and x != self._field.itemtype: + if not isinstance(x, self._field.itemtype) and x != self._field.itemtype: msg = "Value {} at key {!r} is of incorrect type {}. Expected type {}".format( x, k, @@ -76,7 +76,7 @@ def __setitem__(self, k, x, at=None, label="setitem", setHistory=True): if x == dtype: self._dict[k] = dtype(__name=name, __at=at, __label=label) else: - self._dict[k] = dtype(__name=name, __at=at, __label=label, **x._storage) + self._dict[k] = x.__class__(__name=name, __at=at, __label=label, **x._storage) if setHistory: self.history.append(("Added item at key %s" % k, at, label)) else: