Skip to content

Commit

Permalink
Merge pull request #2 from ArthurDeclercq/patch-1
Browse files Browse the repository at this point in the history
update_dict_recursively bug fixes
  • Loading branch information
RalfG authored Nov 15, 2021
2 parents f0027ea + 255a718 commit c605337
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cascade_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def _update_dict_recursively(self, original: Dict, updater: Dict) -> Dict:
"""Update dictionary recursively."""
for k, v in updater.items():
if isinstance(v, dict):
original[k] = self._update_dict_recursively(original.get(k, {}), v)
if not v: # v is not None, v is empty dictionary
original[k] = dict()
else:
original[k] = self._update_dict_recursively(original.get(k, {}), v)
elif isinstance(v, bool):
original[k] = v # v is True or False
elif v or k not in original: # v is not None, or key does not exist yet
original[k] = v
elif self.none_overrides_value: # v is None, but can override previous value
Expand Down

0 comments on commit c605337

Please sign in to comment.