Skip to content

Docs example: copy-mode failure versus partial in-place application #239

Open

Description

@PerchAnton

I prepared an example with a two-operation patch: an early replacement succeeds, then a test operation fails. Separate traces check that copy mode leaves the input unchanged while in-place mode keeps the earlier write. A third covers an escaped pointer and list insertion. These intentionally different results are recorded after each operation.

This documents native behavior and does not add rollback or report the in-place behavior as a bug.

Adapter · three traces · setup and scope · external PR #14.

Python 3.12, jsonpatch 1.37; 3 traces / 9 steps. Linux, Windows and macOS CI.

The JSON runner is my external interaction-check project. Upstream would gain no runtime dependency. Would a short runnable example fit the apply_patch documentation?

Activity

  1. stefankoegl commented on Oct 26, 2026

    @stefankoegl
    Owner

    I'm not sure if I fully understand -- the scope of the linked PR is quite extensive. However...

    Would a short runnable example fit the apply_patch documentation?

    Most likely yes. If you could prepare a PR for the docs, we can take it from there.

  2. PerchAnton commented on Oct 27, 2026

    @PerchAnton
    Author

    Thanks @stefankoegl. The linked PR mixed examples for several libraries, which made the request unclear. I have opened the focused docs PR #243.

    It shows a successful replace followed by a failing test. Both modes raise JsonPatchTestFailed: the default copy mode leaves the input at {'value': 1}, while in_place=True retains the earlier change to {'value': 2}. The example uses jsonpatch.apply_patch directly, with no external runner or new dependency.

    All 7 doctest examples in the added section pass against the current upstream code, and the Sphinx HTML build passes with warnings treated as errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions