MCPcopy Create free account
hub / github.com/Louisym/MiniCC / deep_merge

Function deep_merge

tutorials/09_config_system.py:209–223  ·  view source on GitHub ↗

深度合并两个字典。override 中的值覆盖 base 中的值。 如果两边都是字典,递归合并。 对应源码: config.rs 中的 deep_merge_objects 函数

(base: dict, override: dict)

Source from the content-addressed store, hash-verified

207# 其他部分继承自全局配置。
208
209def deep_merge(base: dict, override: dict) -> dict:
210 """
211 深度合并两个字典。override 中的值覆盖 base 中的值。
212 如果两边都是字典,递归合并。
213
214 对应源码: config.rs 中的 deep_merge_objects 函数
215 """
216 for key, value in override.items():
217 if key in base and isinstance(base[key], dict) and isinstance(value, dict):
218 # 两边都是字典 → 递归合并
219 deep_merge(base[key], value)
220 else:
221 # 否则直接覆盖
222 base[key] = value
223 return base
224
225
226# ============================================================

Callers 2

loadMethod · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected