Skip to content

Commit

Permalink
Allow derived types in ConfigDictField items
Browse files Browse the repository at this point in the history
  • Loading branch information
taranu committed Oct 6, 2023
1 parent 41b076d commit 2495b1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/lsst/pex/config/configDictField.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down

0 comments on commit 2495b1f

Please sign in to comment.