def update_dict(initial: JSON, other: Mapping) -> JSON:
"""Recursively update a dictionary.
:param initial: Dict to update.
:type initial: dict or list
:param other: Dict to update from.
:type other: Mapping
:return: Updated dict.
:rtype: dict
"""
for key, value in other.items():
if isinstance(value, collections.Mapping):
r = update_dict(initial.get(key, {}), value)
initial[key] = r
else:
initial[key] = other[key]
return initial
评论列表
文章目录