Fix testing if JSON elements are mappings

Turns out that the JSON objects extend from dict, so this works.
Also turns out that strings have a __getitem__. Who knew?

Done during Turbo Testing & Tooling.
This commit is contained in:
Ghostkeeper 2019-10-18 16:57:57 +02:00
parent b24dad1563
commit 76b5f9d37b
No known key found for this signature in database
GPG key ID: 59A4C0959592C05C

View file

@ -104,7 +104,7 @@ def merge_dicts(base: Dict[str, Any], overrides: Dict[str, Any]) -> Dict[str, An
result[key] = val result[key] = val
continue continue
if hasattr(result[key], "__getitem__") and hasattr(val, "__getitem__"): # Duck typing of dicts. Also works with JSON documents for sure. if isinstance(result[key], dict) and isinstance(val, dict):
result[key] = merge_dicts(result[key], val) result[key] = merge_dicts(result[key], val)
else: else:
result[key] = val result[key] = val