diff --git a/jsonpatch-stubs/__init__.pyi b/jsonpatch-stubs/__init__.pyi index 1fad29e..efd78cc 100644 --- a/jsonpatch-stubs/__init__.pyi +++ b/jsonpatch-stubs/__init__.pyi @@ -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]: ... diff --git a/typetests/usage.py b/typetests/usage.py index 4b02bb9..c2546d0 100644 --- a/typetests/usage.py +++ b/typetests/usage.py @@ -17,7 +17,8 @@ import jsonpatch from jsonpatch import (InvalidJsonPatch, JsonPatch, JsonPatchConflict, - JsonPatchException, JsonPatchTestFailed, + JsonPatchException, JsonPatchPathNotFound, + JsonPatchTestFailed, PatchOperation) doc = {'foo': 'bar'} @@ -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: