cadwyn 4.0.0__py3-none-any.whl → 4.2.0__py3-none-any.whl
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.
Potentially problematic release.
This version of cadwyn might be problematic. Click here for more details.
- cadwyn/__init__.py +4 -1
- cadwyn/_render.py +4 -4
- cadwyn/applications.py +25 -2
- cadwyn/changelogs.py +499 -0
- cadwyn/route_generation.py +8 -11
- cadwyn/schema_generation.py +53 -39
- cadwyn/structure/common.py +6 -0
- cadwyn/structure/endpoints.py +6 -5
- cadwyn/structure/enums.py +4 -2
- cadwyn/structure/schemas.py +15 -38
- cadwyn/structure/versions.py +25 -16
- {cadwyn-4.0.0.dist-info → cadwyn-4.2.0.dist-info}/METADATA +2 -1
- cadwyn-4.2.0.dist-info/RECORD +28 -0
- cadwyn-4.0.0.dist-info/RECORD +0 -27
- {cadwyn-4.0.0.dist-info → cadwyn-4.2.0.dist-info}/LICENSE +0 -0
- {cadwyn-4.0.0.dist-info → cadwyn-4.2.0.dist-info}/WHEEL +0 -0
- {cadwyn-4.0.0.dist-info → cadwyn-4.2.0.dist-info}/entry_points.txt +0 -0
cadwyn/structure/versions.py
CHANGED
|
@@ -23,7 +23,7 @@ from fastapi.routing import APIRoute, _prepare_response_content
|
|
|
23
23
|
from pydantic import BaseModel
|
|
24
24
|
from pydantic_core import PydanticUndefined
|
|
25
25
|
from starlette._utils import is_async_callable
|
|
26
|
-
from typing_extensions import assert_never
|
|
26
|
+
from typing_extensions import assert_never, deprecated
|
|
27
27
|
|
|
28
28
|
from cadwyn._utils import classproperty
|
|
29
29
|
from cadwyn.exceptions import (
|
|
@@ -64,6 +64,7 @@ IdentifierPythonPath = str
|
|
|
64
64
|
|
|
65
65
|
class VersionChange:
|
|
66
66
|
description: ClassVar[str] = Sentinel
|
|
67
|
+
is_hidden_from_changelog: bool = False
|
|
67
68
|
instructions_to_migrate_to_previous_version: ClassVar[Sequence[PossibleInstructions]] = Sentinel
|
|
68
69
|
alter_schema_instructions: ClassVar[list[AlterSchemaSubInstruction | SchemaHadInstruction]] = Sentinel
|
|
69
70
|
alter_enum_instructions: ClassVar[list[AlterEnumSubInstruction]] = Sentinel
|
|
@@ -198,24 +199,29 @@ class VersionChangeWithSideEffects(VersionChange, _abstract=True):
|
|
|
198
199
|
|
|
199
200
|
|
|
200
201
|
class Version:
|
|
201
|
-
def __init__(self, value: VersionDate | str, *
|
|
202
|
+
def __init__(self, value: VersionDate | str, *changes: type[VersionChange]) -> None:
|
|
202
203
|
super().__init__()
|
|
203
204
|
|
|
204
205
|
if isinstance(value, str):
|
|
205
206
|
value = date.fromisoformat(value)
|
|
206
207
|
self.value = value
|
|
207
|
-
self.
|
|
208
|
+
self.changes = changes
|
|
209
|
+
|
|
210
|
+
@property
|
|
211
|
+
@deprecated("'version_changes' attribute is deprecated and will be removed in Cadwyn 5.x.x. Use 'changes' instead.")
|
|
212
|
+
def version_changes(self): # pragma: no cover
|
|
213
|
+
return self.changes
|
|
208
214
|
|
|
209
215
|
def __repr__(self) -> str:
|
|
210
216
|
return f"Version('{self.value}')"
|
|
211
217
|
|
|
212
218
|
|
|
213
219
|
class HeadVersion:
|
|
214
|
-
def __init__(self, *
|
|
220
|
+
def __init__(self, *changes: type[VersionChange]) -> None:
|
|
215
221
|
super().__init__()
|
|
216
|
-
self.
|
|
222
|
+
self.changes = changes
|
|
217
223
|
|
|
218
|
-
for version_change in
|
|
224
|
+
for version_change in changes:
|
|
219
225
|
if any(
|
|
220
226
|
[
|
|
221
227
|
version_change.alter_request_by_path_instructions,
|
|
@@ -228,6 +234,11 @@ class HeadVersion:
|
|
|
228
234
|
f"HeadVersion does not support request or response migrations but {version_change} contained one."
|
|
229
235
|
)
|
|
230
236
|
|
|
237
|
+
@property
|
|
238
|
+
@deprecated("'version_changes' attribute is deprecated and will be removed in Cadwyn 5.x.x. Use 'changes' instead.")
|
|
239
|
+
def version_changes(self): # pragma: no cover
|
|
240
|
+
return self.changes
|
|
241
|
+
|
|
231
242
|
|
|
232
243
|
def get_cls_pythonpath(cls: type) -> IdentifierPythonPath:
|
|
233
244
|
return f"{cls.__module__}.{cls.__name__}"
|
|
@@ -260,7 +271,7 @@ class VersionBundle:
|
|
|
260
271
|
)
|
|
261
272
|
if not self.versions:
|
|
262
273
|
raise CadwynStructureError("You must define at least one non-head version in a VersionBundle.")
|
|
263
|
-
if self.versions[-1].
|
|
274
|
+
if self.versions[-1].changes:
|
|
264
275
|
raise CadwynStructureError(
|
|
265
276
|
f'The first version "{self.versions[-1].value}" cannot have any version changes. '
|
|
266
277
|
"Version changes are defined to migrate to/from a previous version so you "
|
|
@@ -275,7 +286,7 @@ class VersionBundle:
|
|
|
275
286
|
f"You tried to define two versions with the same value in the same "
|
|
276
287
|
f"{VersionBundle.__name__}: '{version.value}'.",
|
|
277
288
|
)
|
|
278
|
-
for version_change in version.
|
|
289
|
+
for version_change in version.changes:
|
|
279
290
|
if version_change._bound_version_bundle is not None:
|
|
280
291
|
raise CadwynStructureError(
|
|
281
292
|
f"You tried to bind version change '{version_change.__name__}' to two different versions. "
|
|
@@ -295,14 +306,14 @@ class VersionBundle:
|
|
|
295
306
|
altered_schemas = {
|
|
296
307
|
get_cls_pythonpath(instruction.schema): instruction.schema
|
|
297
308
|
for version in self._all_versions
|
|
298
|
-
for version_change in version.
|
|
309
|
+
for version_change in version.changes
|
|
299
310
|
for instruction in list(version_change.alter_schema_instructions)
|
|
300
311
|
}
|
|
301
312
|
|
|
302
313
|
migrated_schemas = {
|
|
303
314
|
get_cls_pythonpath(schema): schema
|
|
304
315
|
for version in self._all_versions
|
|
305
|
-
for version_change in version.
|
|
316
|
+
for version_change in version.changes
|
|
306
317
|
for schema in list(version_change.alter_request_by_schema_instructions.keys())
|
|
307
318
|
}
|
|
308
319
|
|
|
@@ -313,7 +324,7 @@ class VersionBundle:
|
|
|
313
324
|
return {
|
|
314
325
|
get_cls_pythonpath(instruction.enum): instruction.enum
|
|
315
326
|
for version in self._all_versions
|
|
316
|
-
for version_change in version.
|
|
327
|
+
for version_change in version.changes
|
|
317
328
|
for instruction in version_change.alter_enum_instructions
|
|
318
329
|
}
|
|
319
330
|
|
|
@@ -327,9 +338,7 @@ class VersionBundle:
|
|
|
327
338
|
def _version_changes_to_version_mapping(
|
|
328
339
|
self,
|
|
329
340
|
) -> dict[type[VersionChange] | type[VersionChangeWithSideEffects], VersionDate]:
|
|
330
|
-
return {
|
|
331
|
-
version_change: version.value for version in self.versions for version_change in version.version_changes
|
|
332
|
-
}
|
|
341
|
+
return {version_change: version.value for version in self.versions for version_change in version.changes}
|
|
333
342
|
|
|
334
343
|
async def _migrate_request(
|
|
335
344
|
self,
|
|
@@ -347,7 +356,7 @@ class VersionBundle:
|
|
|
347
356
|
for v in reversed(self.versions):
|
|
348
357
|
if v.value <= current_version:
|
|
349
358
|
continue
|
|
350
|
-
for version_change in v.
|
|
359
|
+
for version_change in v.changes:
|
|
351
360
|
if body_type is not None and body_type in version_change.alter_request_by_schema_instructions:
|
|
352
361
|
for instruction in version_change.alter_request_by_schema_instructions[body_type]:
|
|
353
362
|
instruction(request_info)
|
|
@@ -394,7 +403,7 @@ class VersionBundle:
|
|
|
394
403
|
for v in self.versions:
|
|
395
404
|
if v.value <= current_version:
|
|
396
405
|
break
|
|
397
|
-
for version_change in v.
|
|
406
|
+
for version_change in v.changes:
|
|
398
407
|
migrations_to_apply: list[_BaseAlterResponseInstruction] = []
|
|
399
408
|
|
|
400
409
|
if head_response_model and head_response_model in version_change.alter_response_by_schema_instructions:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cadwyn
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
|
|
5
5
|
Home-page: https://github.com/zmievsa/cadwyn
|
|
6
6
|
License: MIT
|
|
@@ -32,6 +32,7 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Classifier: Typing :: Typed
|
|
34
34
|
Provides-Extra: cli
|
|
35
|
+
Requires-Dist: backports-strenum (>=1.3.1,<2.0.0) ; python_version < "3.11"
|
|
35
36
|
Requires-Dist: fastapi (>=0.110.0)
|
|
36
37
|
Requires-Dist: issubclass (>=0.1.2,<0.2.0)
|
|
37
38
|
Requires-Dist: jinja2 (>=3.1.2)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
cadwyn/__init__.py,sha256=w4Iu8rEu9zfptMKsBaWgAj0vJABKGJukKYQBNbuwt1Q,1035
|
|
2
|
+
cadwyn/__main__.py,sha256=fGoKJPNVueqqXW4rqwmRUBBMoDGeLEyATdT-rel5Pvs,2449
|
|
3
|
+
cadwyn/_asts.py,sha256=kNDXS0Ju0pYZyohAmJNVgJpspwKai5_a9tbekkGehUE,5130
|
|
4
|
+
cadwyn/_importer.py,sha256=2mZrDHlfY2heZsMBW-9RBpvKsCk9I-Wa8pxZ6f2f8gY,1074
|
|
5
|
+
cadwyn/_render.py,sha256=LJ-R1TrBgMJpTkJb6pQdRWaMjKyw3R6eTlXXEieqUw0,5466
|
|
6
|
+
cadwyn/_utils.py,sha256=GK9w_qzyOI_o6UaGVfwLLYhnJFMzXistoYI9fq2E9dE,1159
|
|
7
|
+
cadwyn/applications.py,sha256=Ar-wHBp6om5K_g74JsJwMO0NscKPQpUouWg-1H5a2iQ,15495
|
|
8
|
+
cadwyn/changelogs.py,sha256=SdrdAKQ01mpzs-EN_zg-D0TY7wxsibjRjLMhGcI4q80,20066
|
|
9
|
+
cadwyn/exceptions.py,sha256=VlJKRmEGfFTDtHbOWc8kXK4yMi2N172K684Y2UIV8rI,1832
|
|
10
|
+
cadwyn/middleware.py,sha256=8cuBri_yRkl0goe6G0MLwtL04WGbW9Infah3wy9hUVM,3372
|
|
11
|
+
cadwyn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
cadwyn/route_generation.py,sha256=-4HJWH2AoyGuB4qER-Gjc6kgUYUpzo_FoSkw3Gyi6rU,22872
|
|
13
|
+
cadwyn/routing.py,sha256=9AHSojmuLgUAQlLMIqXz-ViZ9n-fljgOsn7oxha7PjM,7341
|
|
14
|
+
cadwyn/schema_generation.py,sha256=rqiKM-Z5owqkvntNeW4j32gVAzn9_ToAxQNHOWEgZ5Y,39967
|
|
15
|
+
cadwyn/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
cadwyn/static/docs.html,sha256=WNm5ANJVy51TcIUFOaqKf1Z8eF86CC85TTHPxACtkzw,3455
|
|
17
|
+
cadwyn/structure/__init__.py,sha256=vej7TdTMSOg8U8Wk7GTNdA4rc6loA9083FWaTg4jAaY,655
|
|
18
|
+
cadwyn/structure/common.py,sha256=GUclfxKLRlFwPjT237fCtLIzdvjvC9gI3acuxBizwbg,414
|
|
19
|
+
cadwyn/structure/data.py,sha256=1ALPhBBCE_t4GrxM0Fa3hQ-jkORJgeWNySnZ42bsi0g,7382
|
|
20
|
+
cadwyn/structure/endpoints.py,sha256=9FFnbqPM9v0CP6J6tGhMNKVvWqA9u3ZjI2Fannr2Rl0,5933
|
|
21
|
+
cadwyn/structure/enums.py,sha256=bZL-iUOUFi9ZYlMZJw-tAix2yrgCp3gH3N2gwO44LUU,1043
|
|
22
|
+
cadwyn/structure/schemas.py,sha256=D0BD1D3v9MRdVWchU9JM2zHd0dvB0UgXHDGFCe5aQZc,8209
|
|
23
|
+
cadwyn/structure/versions.py,sha256=cyBSVyYwe50V8g19G7y2rIFR6OxSVAF9Q98u1GNZiyU,32533
|
|
24
|
+
cadwyn-4.2.0.dist-info/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
|
|
25
|
+
cadwyn-4.2.0.dist-info/METADATA,sha256=X7fWn-_w1M3y189xXqfh2Os2se0yTlnnl2COTRfuXSo,4420
|
|
26
|
+
cadwyn-4.2.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
27
|
+
cadwyn-4.2.0.dist-info/entry_points.txt,sha256=eO05hLn9GoRzzpwT9GONPmXKsonjuMNssM2D2WHWKGk,46
|
|
28
|
+
cadwyn-4.2.0.dist-info/RECORD,,
|
cadwyn-4.0.0.dist-info/RECORD
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
cadwyn/__init__.py,sha256=N98kE6Eb7g7mH-YW1XuAqb084W2NKvPhA1cUs_O0nak,930
|
|
2
|
-
cadwyn/__main__.py,sha256=fGoKJPNVueqqXW4rqwmRUBBMoDGeLEyATdT-rel5Pvs,2449
|
|
3
|
-
cadwyn/_asts.py,sha256=kNDXS0Ju0pYZyohAmJNVgJpspwKai5_a9tbekkGehUE,5130
|
|
4
|
-
cadwyn/_importer.py,sha256=2mZrDHlfY2heZsMBW-9RBpvKsCk9I-Wa8pxZ6f2f8gY,1074
|
|
5
|
-
cadwyn/_render.py,sha256=-eY4zMzBEJPteDF_CRwJah5DWFmUl2zHQHrb21mcfb8,5482
|
|
6
|
-
cadwyn/_utils.py,sha256=GK9w_qzyOI_o6UaGVfwLLYhnJFMzXistoYI9fq2E9dE,1159
|
|
7
|
-
cadwyn/applications.py,sha256=g4VlB3SzQMjfAq5vX8u6DYj2OZei2oGBffSUTVVyaAA,14478
|
|
8
|
-
cadwyn/exceptions.py,sha256=VlJKRmEGfFTDtHbOWc8kXK4yMi2N172K684Y2UIV8rI,1832
|
|
9
|
-
cadwyn/middleware.py,sha256=8cuBri_yRkl0goe6G0MLwtL04WGbW9Infah3wy9hUVM,3372
|
|
10
|
-
cadwyn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
cadwyn/route_generation.py,sha256=GiCUCAKFQoIID3Zv5dYGTIbsGu3TSxDnB62ZUH-Mh58,22961
|
|
12
|
-
cadwyn/routing.py,sha256=9AHSojmuLgUAQlLMIqXz-ViZ9n-fljgOsn7oxha7PjM,7341
|
|
13
|
-
cadwyn/schema_generation.py,sha256=SZoP0IPgVdlJ015ItW5dxwvlWYcA41Lx1pQzCOwV7TE,39386
|
|
14
|
-
cadwyn/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
cadwyn/static/docs.html,sha256=WNm5ANJVy51TcIUFOaqKf1Z8eF86CC85TTHPxACtkzw,3455
|
|
16
|
-
cadwyn/structure/__init__.py,sha256=vej7TdTMSOg8U8Wk7GTNdA4rc6loA9083FWaTg4jAaY,655
|
|
17
|
-
cadwyn/structure/common.py,sha256=6Z4nI97XPWTCinn6np73m-rLPyYNrz2fWXKJlqjsiaQ,269
|
|
18
|
-
cadwyn/structure/data.py,sha256=1ALPhBBCE_t4GrxM0Fa3hQ-jkORJgeWNySnZ42bsi0g,7382
|
|
19
|
-
cadwyn/structure/endpoints.py,sha256=JhTgVrqLjm5LkE9thjvU1UuWcSCmDgW2bMdqznsZb2Y,5777
|
|
20
|
-
cadwyn/structure/enums.py,sha256=iMokxA2QYJ61SzyB-Pmuq3y7KL7-e6TsnjLVUaVZQnw,954
|
|
21
|
-
cadwyn/structure/schemas.py,sha256=dfVeVL6R6RjcNeehbd4yPlCYCkpiHi0Ujrwkq4pCvd8,9285
|
|
22
|
-
cadwyn/structure/versions.py,sha256=3SXzQD9Ps3jukF6prhGTABUAik70jd7KebTApY8B3Ns,32190
|
|
23
|
-
cadwyn-4.0.0.dist-info/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
|
|
24
|
-
cadwyn-4.0.0.dist-info/METADATA,sha256=0Exz0MGTvNEndoEkQ4xJ8Nn_c3Puk52utPDTJtrCIx0,4344
|
|
25
|
-
cadwyn-4.0.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
26
|
-
cadwyn-4.0.0.dist-info/entry_points.txt,sha256=eO05hLn9GoRzzpwT9GONPmXKsonjuMNssM2D2WHWKGk,46
|
|
27
|
-
cadwyn-4.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|