Skip to content

Honor optimization=False when generating patches - #233

Merged
stefankoegl merged 1 commit into
stefankoegl:masterfrom
Apeksha9389:fix/honor-diff-optimization
Oct 19, 2026
Merged

stefankoegl merged 1 commit into
stefankoegl:masterfrom
Apeksha9389:fix/honor-diff-optimization

Conversation

@Apeksha9389

Copy link
Copy Markdown
Contributor

JsonPatch.from_diff(..., optimization=False) currently still produces move operations. This prevents using generated patches with consumers that support only add, remove, and replace, as reported in #172.

Pass the existing option to the diff builder and disable matching added and removed values when it is false. The default behavior stays enabled. The option is documented on from_diff.

Fixes #172.

Validation: four reproductions failed before the fix. All 210 unit tests and 20 property tests pass after it, including a new generated-document round-trip test without move optimization. Coverage includes object renames, array reordering, nested values, escaped pointer keys, and source immutability. The CI fatal-error Flake8 selection and git diff --check pass.

AI-assisted implementation and tests.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — Apeksha9389:fix/honor-diff-optimization into stefankoegl:master

@stefankoegl
stefankoegl merged commit dc04359 into stefankoegl:master Oct 19, 2026
12 checks passed
@stefankoegl

Copy link
Copy Markdown
Owner

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow disabling complex operations

3 participants