You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hash(JsonPatch) raises TypeError when an operation's value is an array or object #217
So such patches can't go into sets or serve as dict keys, while patches with scalar values can.
Cause:PatchOperation.__hash__ returns hash(frozenset(self.operation.items())), which requires every member value to be hashable.
Suggested fix: hash only op, path and from. Operations that compare equal still get equal hashes. Hashing a json.dumps of the whole operation would break that while __eq__ uses Python equality: {'value': 1}, {'value': 1.0} and {'value': True} compare equal but serialize differently (see #216).
Test:JsonPatchProperties.test_equal_patches_have_equal_hashes in property_tests.py is marked @unittest.expectedFailure because of this bug.
Fixed by ccb5228 ("Hash patch operations by their 'op' and 'path'"), merged in #220.
On current master (077b4f4), patches whose values are arrays or objects can be hashed, and equal patches get equal hashes. test_equal_patches_have_equal_hashes in property_tests.py no longer carries expectedFailure and passes, at 5,000 examples on two hash seeds as well.
Activity
stefankoegl commentedon Oct 10, 2026
Fixed by ccb5228 ("Hash patch operations by their 'op' and 'path'"), merged in #220.
On current master (077b4f4), patches whose values are arrays or objects can be hashed, and equal patches get equal hashes.
test_equal_patches_have_equal_hashesinproperty_tests.pyno longer carriesexpectedFailureand passes, at 5,000 examples on two hash seeds as well.Generated by Claude Code