Skip to main content
Version: latest

agrag.candidates.patch.write_patch

write_patch(patch:SchemaPatch, path:Path, *, overwrite:bool = False) -> Path

Write the patch as indented JSON, refusing replacement by default.

The file is created or truncated only after opening it in exclusive-create or write mode. A trailing newline is included.

Parameters:

  • patch (SchemaPatch) – Patch to serialize.
  • path (Path) – Destination file path.
  • overwrite (bool) – Whether to truncate an existing file.

Returns:

  • Path – The destination path after a successful write.

Raises:

  • FileExistsError – If the destination exists and overwrite is false.
  • OSError – If the destination cannot be opened or written.