Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jsonpatch-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class JsonPatchException(Exception):

class InvalidJsonPatch(JsonPatchException): ...
class JsonPatchConflict(JsonPatchException): ...
class JsonPatchPathNotFound(JsonPatchConflict): ...
class JsonPatchTestFailed(JsonPatchException, AssertionError): ...

def multidict(ordered_pairs: Iterable[tuple[str, Any]]) -> dict[str, Any]: ...
Expand Down
8 changes: 7 additions & 1 deletion typetests/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

import jsonpatch
from jsonpatch import (InvalidJsonPatch, JsonPatch, JsonPatchConflict,
JsonPatchException, JsonPatchTestFailed,
JsonPatchException, JsonPatchPathNotFound,
JsonPatchTestFailed,
PatchOperation)

doc = {'foo': 'bar'}
Expand Down Expand Up @@ -85,6 +86,11 @@ class MyPointer(JsonPointer):
assert_type(ex, InvalidJsonPatch | JsonPatchConflict | JsonPatchTestFailed)
failed = ex.op
JsonPatchException('message', op=None)
try:
patch.apply(doc)
except JsonPatchPathNotFound as ex:
assert_type(ex, JsonPatchPathNotFound)
conflict: JsonPatchConflict = ex

# names that jsonpatch re-exports from jsonpointer
try:
Expand Down
Loading