[docs]defdeep_update(dest:MutableMapping[K,Any],update:Mapping[L,Any])->MutableMapping[K|L,Any]:""" Recursively update one JSON structure with another. Only dives into nested dicts; lists get replaced completely. If the original value is a dictionary and the new value is not, or vice versa, we also replace the value completely. """dest_int=cast(MutableMapping[K|L,Any],dest)fork,v_updateinupdate.items():v_dest=dest_int.get(k)ifisinstance(v_update,abc.Mapping)andisinstance(v_dest,abc.MutableMapping):deep_update(v_dest,v_update)else:dest_int[k]=deepcopy(v_update)returndest_int