MCPcopy Create free account
hub / github.com/ipython/traitlets / recursive_update

Function recursive_update

traitlets/config/manager.py:16–34  ·  view source on GitHub ↗

Recursively update one dictionary using another. None values will delete their keys.

(target: dict[Any, Any], new: dict[Any, Any])

Source from the content-addressed store, hash-verified

14
15
16def recursive_update(target: dict[Any, Any], new: dict[Any, Any]) -> None:
17 """Recursively update one dictionary using another.
18
19 None values will delete their keys.
20 """
21 for k, v in new.items():
22 if isinstance(v, dict):
23 if k not in target:
24 target[k] = {}
25 recursive_update(target[k], v)
26 if not target[k]:
27 # Prune empty subdicts
28 del target[k]
29
30 elif v is None:
31 target.pop(k, None)
32
33 else:
34 target[k] = v
35
36
37class BaseJSONConfigManager(LoggingConfigurable):

Callers 1

updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…