a = {'a' : {'a' : 'some value'}}
b = {'a' : {'b' : 'some_value'}}
a
. На выходе должно быть подобное.updated = {'a' : {'a' : 'some value', 'b' : 'some_value}}
from collections.abc import Mapping
def __deep_update(source : dict, overrides : dict):
for key, value in overrides.items():
if isinstance(value, Mapping) and value:
returned = __deep_update(source.get(key, {}), value)
source[key] = returned
else:
source[key] = overrides[key]
return source