Skip to content

Commit

Permalink
Recursively convert dict to AttrDict when making an AttrDict (#1154)
Browse files Browse the repository at this point in the history
Dicts within an AttrDict were not being converted to AttrDicts at
creation/update time. This meant (among other things) when updating,
nested dicts of the same name would be overwritten instead of merged.
  • Loading branch information
WalterKolczynski-NOAA authored Dec 7, 2022
1 parent 21056c1 commit cab4faf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ush/python/pygw/src/pygw/attrdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __setitem__(self, name, value):
object.__getattribute__(self, '__frozen'))
if isFrozen and name not in super(AttrDict, self).keys():
raise KeyError(name)
if isinstance(value, dict):
value = AttrDict(value)
super(AttrDict, self).__setitem__(name, value)
try:
p = object.__getattribute__(self, '__parent')
Expand Down

0 comments on commit cab4faf

Please sign in to comment.