From f27e30dfed59339c046103b8a0ff36761f5f7f9c Mon Sep 17 00:00:00 2001 From: ArthurDeclercq Date: Mon, 15 Nov 2021 09:58:32 +0100 Subject: [PATCH 1/2] update_dict_recursively bug fixes Allow for values to be false, and allow to set an empty dict as value --- cascade_config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cascade_config.py b/cascade_config.py index a6a5573..293998f 100644 --- a/cascade_config.py +++ b/cascade_config.py @@ -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 isintance(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 From 255a718615842756ce132f8efe36f93c4f32bf18 Mon Sep 17 00:00:00 2001 From: Ralf Gabriels Date: Mon, 15 Nov 2021 10:11:13 +0100 Subject: [PATCH 2/2] Fix typo --- cascade_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cascade_config.py b/cascade_config.py index 293998f..d77e3dd 100644 --- a/cascade_config.py +++ b/cascade_config.py @@ -59,7 +59,7 @@ def _update_dict_recursively(self, original: Dict, updater: Dict) -> Dict: original[k] = dict() else: original[k] = self._update_dict_recursively(original.get(k, {}), v) - elif isintance(v, bool): + 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