pydantic-json-patch 0.6.2__tar.gz → 0.6.3__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-0.6.2 → pydantic_json_patch-0.6.3}/PKG-INFO +5 -2
- {pydantic_json_patch-0.6.2 → pydantic_json_patch-0.6.3}/README.md +4 -1
- {pydantic_json_patch-0.6.2 → pydantic_json_patch-0.6.3}/pyproject.toml +2 -1
- {pydantic_json_patch-0.6.2 → pydantic_json_patch-0.6.3}/src/pydantic_json_patch/models.py +26 -17
- {pydantic_json_patch-0.6.2 → pydantic_json_patch-0.6.3}/src/pydantic_json_patch/__init__.py +0 -0
- {pydantic_json_patch-0.6.2 → pydantic_json_patch-0.6.3}/src/pydantic_json_patch/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic_json_patch
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Pydantic models for implementing JSON Patch.
|
|
5
5
|
Author: Jonathan Sharpe
|
|
6
6
|
Author-email: Jonathan Sharpe <mail@jonrshar.pe>
|
|
@@ -176,7 +176,10 @@ def _(
|
|
|
176
176
|
...
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
**
|
|
179
|
+
**Notes**:
|
|
180
|
+
|
|
181
|
+
- Explicitly specifying the [discriminator][pydantic-discriminator] gives better results on _failed_ validation for unions of operations; and
|
|
182
|
+
- Parameterised versions of the operations will also appear in the JSON Schema as e.g. `AddOp_int_` (with the title _"JsonPatchAddOperation\[int\]"_).
|
|
180
183
|
|
|
181
184
|
## Development
|
|
182
185
|
|
|
@@ -144,7 +144,10 @@ def _(
|
|
|
144
144
|
...
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
**
|
|
147
|
+
**Notes**:
|
|
148
|
+
|
|
149
|
+
- Explicitly specifying the [discriminator][pydantic-discriminator] gives better results on _failed_ validation for unions of operations; and
|
|
150
|
+
- Parameterised versions of the operations will also appear in the JSON Schema as e.g. `AddOp_int_` (with the title _"JsonPatchAddOperation\[int\]"_).
|
|
148
151
|
|
|
149
152
|
## Development
|
|
150
153
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pydantic_json_patch"
|
|
3
|
-
version = "0.6.
|
|
3
|
+
version = "0.6.3"
|
|
4
4
|
description = "Pydantic models for implementing JSON Patch."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -49,6 +49,7 @@ dev = [
|
|
|
49
49
|
"fastapi-cli>=0.0.20",
|
|
50
50
|
"httpx>=0.28.1",
|
|
51
51
|
"isort>=7.0.0",
|
|
52
|
+
"joythief>=0.8.1",
|
|
52
53
|
"pre-commit>=4.5.1",
|
|
53
54
|
"pytest>=9.0.2",
|
|
54
55
|
"ruff>=0.15.0",
|
|
@@ -24,9 +24,9 @@ T = tx.TypeVar("T", default=tp.Any)
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def _generate_title(model: type[tp.Any]) -> str:
|
|
27
|
-
"""
|
|
28
|
-
name, *
|
|
29
|
-
return
|
|
27
|
+
"""Prefix with 'JsonPatch' and expand 'Op' contraction."""
|
|
28
|
+
name, *rest = model.__name__.partition("[")
|
|
29
|
+
return "".join(("JsonPatch", name, "eration", *rest))
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class _BaseOp(BaseModel):
|
|
@@ -108,6 +108,15 @@ class _FromOp(_BaseOp):
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
class _ValueOp(_BaseOp, tp.Generic[T]):
|
|
111
|
+
@classmethod
|
|
112
|
+
def __class_getitem__(
|
|
113
|
+
cls, typevar_values: type[tp.Any] | tuple[type[tp.Any], ...]
|
|
114
|
+
) -> type[BaseModel]:
|
|
115
|
+
"""Propagate docstring to generic alias."""
|
|
116
|
+
alias = super().__class_getitem__(typevar_values)
|
|
117
|
+
alias.__doc__ = cls.__doc__
|
|
118
|
+
return alias
|
|
119
|
+
|
|
111
120
|
@classmethod
|
|
112
121
|
def create(cls, *, path: str | Sequence[str], value: T) -> tx.Self: # ty: ignore[invalid-method-override] -- deliberately narrows **kwargs to named params
|
|
113
122
|
"""Return an instance of the appropriate operation."""
|
|
@@ -123,9 +132,9 @@ class _ValueOp(_BaseOp, tp.Generic[T]):
|
|
|
123
132
|
|
|
124
133
|
|
|
125
134
|
class AddOp(_ValueOp[T], tp.Generic[T]):
|
|
126
|
-
"""Represents the
|
|
135
|
+
"""Represents the [add] operation.
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
[add]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.1
|
|
129
138
|
|
|
130
139
|
"""
|
|
131
140
|
|
|
@@ -133,9 +142,9 @@ class AddOp(_ValueOp[T], tp.Generic[T]):
|
|
|
133
142
|
|
|
134
143
|
|
|
135
144
|
class CopyOp(_FromOp):
|
|
136
|
-
"""Represents the
|
|
145
|
+
"""Represents the [copy] operation.
|
|
137
146
|
|
|
138
|
-
|
|
147
|
+
[copy]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.5
|
|
139
148
|
|
|
140
149
|
"""
|
|
141
150
|
|
|
@@ -143,9 +152,9 @@ class CopyOp(_FromOp):
|
|
|
143
152
|
|
|
144
153
|
|
|
145
154
|
class MoveOp(_FromOp):
|
|
146
|
-
"""Represents the
|
|
155
|
+
"""Represents the [move] operation.
|
|
147
156
|
|
|
148
|
-
|
|
157
|
+
[move]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.4
|
|
149
158
|
|
|
150
159
|
"""
|
|
151
160
|
|
|
@@ -153,9 +162,9 @@ class MoveOp(_FromOp):
|
|
|
153
162
|
|
|
154
163
|
|
|
155
164
|
class RemoveOp(_BaseOp):
|
|
156
|
-
"""Represents the
|
|
165
|
+
"""Represents the [remove] operation.
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
[remove]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.2
|
|
159
168
|
|
|
160
169
|
"""
|
|
161
170
|
|
|
@@ -168,9 +177,9 @@ class RemoveOp(_BaseOp):
|
|
|
168
177
|
|
|
169
178
|
|
|
170
179
|
class ReplaceOp(_ValueOp[T], tp.Generic[T]):
|
|
171
|
-
"""Represents the
|
|
180
|
+
"""Represents the [replace] operation.
|
|
172
181
|
|
|
173
|
-
|
|
182
|
+
[replace]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.3
|
|
174
183
|
|
|
175
184
|
"""
|
|
176
185
|
|
|
@@ -178,9 +187,9 @@ class ReplaceOp(_ValueOp[T], tp.Generic[T]):
|
|
|
178
187
|
|
|
179
188
|
|
|
180
189
|
class TestOp(_ValueOp[T], tp.Generic[T]):
|
|
181
|
-
"""Represents the
|
|
190
|
+
"""Represents the [test] operation.
|
|
182
191
|
|
|
183
|
-
|
|
192
|
+
[test]: https://datatracker.ietf.org/doc/html/rfc6902/#section-4.6
|
|
184
193
|
|
|
185
194
|
"""
|
|
186
195
|
|
|
@@ -198,9 +207,9 @@ Operation: tp.TypeAlias = tp.Annotated[
|
|
|
198
207
|
|
|
199
208
|
|
|
200
209
|
class JsonPatch(RootModel[Sequence[Operation]], Sequence[Operation]):
|
|
201
|
-
"""Represents a full JSON Patch
|
|
210
|
+
"""Represents a full JSON Patch [document].
|
|
202
211
|
|
|
203
|
-
|
|
212
|
+
[document]: https://datatracker.ietf.org/doc/html/rfc6902/#section-3
|
|
204
213
|
|
|
205
214
|
"""
|
|
206
215
|
|
|
File without changes
|
|
File without changes
|