MCPcopy
hub / github.com/pydantic/pydantic / deep_update

Function deep_update

pydantic/_internal/_utils.py:133–141  ·  view source on GitHub ↗
(mapping: dict[KeyType, Any], *updating_mappings: dict[KeyType, Any])

Source from the content-addressed store, hash-verified

131
132
133def deep_update(mapping: dict[KeyType, Any], *updating_mappings: dict[KeyType, Any]) -> dict[KeyType, Any]:
134 updated_mapping = mapping.copy()
135 for updating_mapping in updating_mappings:
136 for k, v in updating_mapping.items():
137 if k in updated_mapping and isinstance(updated_mapping[k], dict) and isinstance(v, dict):
138 updated_mapping[k] = deep_update(updated_mapping[k], v)
139 else:
140 updated_mapping[k] = v
141 return updated_mapping
142
143
144def update_not_none(mapping: dict[Any, Any], **update: Any) -> None:

Callers 2

test_deep_updateFunction · 0.90

Calls 2

copyMethod · 0.45
itemsMethod · 0.45

Tested by 2

test_deep_updateFunction · 0.72