MCPcopy Index your code
hub / github.com/github/spec-kit / deep_merge_polite

Function deep_merge_polite

src/specify_cli/_utils.py:267–281  ·  view source on GitHub ↗

Recursively merge update dict into base dict, preserving base values.

(base: dict[str, Any], update: dict[str, Any])

Source from the content-addressed store, hash-verified

265 return None
266
267 def deep_merge_polite(base: dict[str, Any], update: dict[str, Any]) -> dict[str, Any]:
268 """Recursively merge update dict into base dict, preserving base values."""
269 result = base.copy()
270 for key, value in update.items():
271 if key not in result:
272 # Add new key
273 result[key] = value
274 elif isinstance(result[key], dict) and isinstance(value, dict):
275 # Recursively merge nested dictionaries
276 result[key] = deep_merge_polite(result[key], value)
277 else:
278 # Key already exists and values are not both dicts; preserve existing value.
279 # This ensures user settings aren't overwritten by template defaults.
280 pass
281 return result
282
283 merged = deep_merge_polite(existing_content, new_content)
284

Callers 1

merge_json_filesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected