patch_ops#

iter_patch_items(p: Any, *, _path: tuple[str, ...] = ())[source]#

Yield (path, value) for leaf assignments in a patch dict. A leaf is any non-dict value (including DELETE/_REPLACE/scalar/list).

merge_patches(dst: dict, src: dict, *, _path: Tuple[str, ...] = ()) dict[source]#

Combine two patch dicts without applying them.

Composition rules:
  • DELETE and _REPLACE are strong operations.

  • dict values recurse (merge).

  • scalars overwrite.

Conflict rules:
  • dst already has _REPLACE and src has different _REPLACE => raise.

  • dst already has _REPLACE and src provides a non-sentinel update => raise (prevents silent downgrade of authoritative replacement).

set_patch_at_path(patch: Dict[str, Any], path: Tuple[str, ...], value: Any) None[source]#