pydantic-json-patch 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydantic_json_patch-2.1.0/LICENSE +13 -0
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/PKG-INFO +2 -2
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/pyproject.toml +6 -3
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/src/pydantic_json_patch/models.py +18 -15
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/README.md +0 -0
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/src/pydantic_json_patch/__init__.py +0 -0
- {pydantic_json_patch-2.0.0 → pydantic_json_patch-2.1.0}/src/pydantic_json_patch/py.typed +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2026-present, Jonathan Sharpe
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic_json_patch
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Pydantic models for implementing JSON Patch.
|
|
5
5
|
Author: Jonathan Sharpe
|
|
6
6
|
Author-email: Jonathan Sharpe <mail@jonrshar.pe>
|
|
7
7
|
License-Expression: ISC
|
|
8
|
+
License-File: LICENSE
|
|
8
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
9
10
|
Classifier: Framework :: FastAPI
|
|
10
11
|
Classifier: Framework :: Pydantic
|
|
11
12
|
Classifier: Framework :: Pydantic :: 2
|
|
12
13
|
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: ISC License (ISCL)
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pydantic_json_patch"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.1.0"
|
|
4
4
|
description = "Pydantic models for implementing JSON Patch."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -12,13 +12,13 @@ dependencies = [
|
|
|
12
12
|
"typing-extensions>=4.14.1",
|
|
13
13
|
]
|
|
14
14
|
license = "ISC"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
15
16
|
classifiers = [
|
|
16
17
|
"Development Status :: 5 - Production/Stable",
|
|
17
18
|
"Framework :: FastAPI",
|
|
18
19
|
"Framework :: Pydantic",
|
|
19
20
|
"Framework :: Pydantic :: 2",
|
|
20
21
|
"Intended Audience :: Developers",
|
|
21
|
-
"License :: OSI Approved :: ISC License (ISCL)",
|
|
22
22
|
"Operating System :: OS Independent",
|
|
23
23
|
"Programming Language :: Python",
|
|
24
24
|
"Programming Language :: Python :: 3",
|
|
@@ -38,7 +38,7 @@ Issues = "https://github.com/textbook/pydantic_json_patch/issues"
|
|
|
38
38
|
Sponsor = "https://ko-fi.com/textbook"
|
|
39
39
|
|
|
40
40
|
[build-system]
|
|
41
|
-
requires = ["uv_build>=0.9.27,<0.
|
|
41
|
+
requires = ["uv_build>=0.9.27,<0.12.0"]
|
|
42
42
|
build-backend = "uv_build"
|
|
43
43
|
|
|
44
44
|
[dependency-groups]
|
|
@@ -101,3 +101,6 @@ ignore = [
|
|
|
101
101
|
"bin/**/*.py" = [
|
|
102
102
|
"D",
|
|
103
103
|
]
|
|
104
|
+
|
|
105
|
+
[tool.ty.terminal]
|
|
106
|
+
error-on-warning = true
|
|
@@ -16,6 +16,7 @@ from pydantic import (
|
|
|
16
16
|
model_validator,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
+
_CACHE_SIZE = 1_024 # pragma: no mutate
|
|
19
20
|
_JSON_POINTER = re.compile(r"^(?:/(?:[^/~]|~[01])*)*$")
|
|
20
21
|
|
|
21
22
|
T = tx.TypeVar("T", default=tp.Any)
|
|
@@ -32,6 +33,16 @@ def _generate_title(model: type[tp.Any]) -> str:
|
|
|
32
33
|
return "".join(("JsonPatch", name, "eration", *rest))
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
@lru_cache(maxsize=_CACHE_SIZE)
|
|
37
|
+
def _decode_token(token: str) -> str:
|
|
38
|
+
return token.replace("~1", "/").replace("~0", "~")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@lru_cache(maxsize=_CACHE_SIZE)
|
|
42
|
+
def _encode_token(token: str) -> str:
|
|
43
|
+
return token.replace("~", "~0").replace("/", "~1")
|
|
44
|
+
|
|
45
|
+
|
|
35
46
|
class _BaseOp(BaseModel):
|
|
36
47
|
model_config = ConfigDict(
|
|
37
48
|
frozen=True,
|
|
@@ -60,22 +71,12 @@ class _BaseOp(BaseModel):
|
|
|
60
71
|
def _dump_pointer(cls, pointer: Sequence[str]) -> str:
|
|
61
72
|
if isinstance(pointer, str):
|
|
62
73
|
return pointer
|
|
63
|
-
return "/".join(["", *(
|
|
74
|
+
return "/".join(["", *(_encode_token(token) for token in pointer)])
|
|
64
75
|
|
|
65
76
|
@staticmethod
|
|
66
|
-
@lru_cache
|
|
67
|
-
def
|
|
68
|
-
return token.
|
|
69
|
-
|
|
70
|
-
@staticmethod
|
|
71
|
-
@lru_cache
|
|
72
|
-
def _encode_token(token: str) -> str:
|
|
73
|
-
return token.replace("~", "~0").replace("/", "~1")
|
|
74
|
-
|
|
75
|
-
@classmethod
|
|
76
|
-
@lru_cache
|
|
77
|
-
def _load_pointer(cls, pointer: str) -> tuple[str, ...]:
|
|
78
|
-
return tuple(cls._decode_token(token) for token in pointer.split("/")[1:])
|
|
77
|
+
@lru_cache(maxsize=_CACHE_SIZE)
|
|
78
|
+
def _load_pointer(pointer: str) -> tuple[str, ...]:
|
|
79
|
+
return tuple(_decode_token(token) for token in pointer.split("/")[1:])
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
class _FromOp(_BaseOp):
|
|
@@ -223,7 +224,9 @@ class JsonPatch(RootModel[Sequence[Operation]], Sequence[Operation]):
|
|
|
223
224
|
@model_validator(mode="before")
|
|
224
225
|
@classmethod
|
|
225
226
|
def _coerce_seq_to_tuple(cls, value: tp.Any) -> tp.Any: # noqa: ANN401
|
|
226
|
-
if isinstance(value,
|
|
227
|
+
if isinstance(value, tuple):
|
|
228
|
+
return value
|
|
229
|
+
if isinstance(value, Sequence):
|
|
227
230
|
return tuple(value)
|
|
228
231
|
return value
|
|
229
232
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|