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 Jan 23, 2024
1 parent ba4ed39 commit a2cdc06
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 @@ -72,7 +72,7 @@ def __setitem__(self, k, x, at=None, label="setitem", setHistory=True):

# validate itemtype
dtype = self._field.itemtype
if type(x) is not 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 @@ -89,7 +89,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 a2cdc06

Please sign in to comment.