Skip to content

Hash patch operations by their 'op' and 'path' (#217) - #220

Merged
stefankoegl merged 1 commit into
masterfrom
claude/dazzling-mccarthy-m9l5t8
Oct 9, 2026
Merged

stefankoegl merged 1 commit into
masterfrom
claude/dazzling-mccarthy-m9l5t8

Conversation

@stefankoegl

Copy link
Copy Markdown
Owner

PatchOperation.hash hashed a frozenset of all members, so hashing a
patch raised TypeError when an operation's value was an array or object.
Such patches couldn't go into sets or serve as dict keys.

Hash only 'op' and 'path'. They are always hashable, since 'op' must be
a string and 'path' a valid pointer, and operations that compare equal
have equal 'op' and 'path', so their hashes stay equal. 'from' is left
out: it is only validated when a move or copy is applied, and the RFC
has other operations ignore it, so it can hold an array or object too.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_011nVTdpJFksiRYmZDJrV9SM

PatchOperation.__hash__ hashed a frozenset of all members, so hashing a
patch raised TypeError when an operation's value was an array or object.
Such patches couldn't go into sets or serve as dict keys.

Hash only 'op' and 'path'. They are always hashable, since 'op' must be
a string and 'path' a valid pointer, and operations that compare equal
have equal 'op' and 'path', so their hashes stay equal. 'from' is left
out: it is only validated when a move or copy is applied, and the RFC
has other operations ignore it, so it can hold an array or object too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nVTdpJFksiRYmZDJrV9SM
@stefankoegl
stefankoegl merged commit 8d01644 into master Oct 9, 2026
5 checks passed
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.

2 participants