Files
OpenHands/openhands/utils/jsonpatch_compat.py
Graham Neubig b4da0e1c69 settings: expose SDK settings schema to OpenHands (#13306)
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: hieptl <hieptl.developer@gmail.com>
Co-authored-by: tofarr <tofarr@gmail.com>
2026-04-15 17:00:35 -06:00

25 lines
706 B
Python

from __future__ import annotations
from typing import Any
def deep_merge(
base: dict[str, Any],
updates: dict[str, Any],
) -> dict[str, Any]:
"""Recursively merge *updates* into a shallow copy of *base*.
* Nested dicts are merged recursively.
* ``None`` values in *updates* remove the corresponding key.
* All other values overwrite.
"""
result: dict[str, Any] = dict(base)
for key, value in updates.items():
if value is None:
result.pop(key, None)
elif isinstance(value, dict) and isinstance(result.get(key), dict):
result[key] = deep_merge(result[key], value)
else:
result[key] = value
return result