cadwyn 3.12.0__py3-none-any.whl → 3.12.1__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/__main__.py +1 -2
- cadwyn/codegen/_main.py +2 -4
- cadwyn/route_generation.py +2 -4
- cadwyn/routing.py +4 -5
- cadwyn/structure/data.py +4 -8
- cadwyn/structure/versions.py +23 -13
- {cadwyn-3.12.0.dist-info → cadwyn-3.12.1.dist-info}/METADATA +1 -1
- {cadwyn-3.12.0.dist-info → cadwyn-3.12.1.dist-info}/RECORD +11 -11
- {cadwyn-3.12.0.dist-info → cadwyn-3.12.1.dist-info}/LICENSE +0 -0
- {cadwyn-3.12.0.dist-info → cadwyn-3.12.1.dist-info}/WHEEL +0 -0
- {cadwyn-3.12.0.dist-info → cadwyn-3.12.1.dist-info}/entry_points.txt +0 -0
cadwyn/__main__.py
CHANGED
|
@@ -115,8 +115,7 @@ def _get_version_bundle(possibly_version_bundle: Any) -> VersionBundle:
|
|
|
115
115
|
@app.callback()
|
|
116
116
|
def main(
|
|
117
117
|
version: bool = typer.Option(None, "-V", "--version", callback=version_callback, is_eager=True),
|
|
118
|
-
):
|
|
119
|
-
...
|
|
118
|
+
): ...
|
|
120
119
|
|
|
121
120
|
|
|
122
121
|
if __name__ == "__main__":
|
cadwyn/codegen/_main.py
CHANGED
|
@@ -53,8 +53,7 @@ def generate_code_for_versioned_packages(
|
|
|
53
53
|
codegen_plugins: Sequence[CodegenPlugin] = DEFAULT_CODEGEN_PLUGINS,
|
|
54
54
|
migration_plugins: Sequence[MigrationPlugin] = DEFAULT_CODEGEN_MIGRATION_PLUGINS,
|
|
55
55
|
extra_context: dict[str, Any] | None = None,
|
|
56
|
-
):
|
|
57
|
-
...
|
|
56
|
+
): ...
|
|
58
57
|
|
|
59
58
|
|
|
60
59
|
@overload
|
|
@@ -70,8 +69,7 @@ def generate_code_for_versioned_packages(
|
|
|
70
69
|
codegen_plugins: Sequence[CodegenPlugin] = DEFAULT_CODEGEN_PLUGINS,
|
|
71
70
|
migration_plugins: Sequence[MigrationPlugin] = DEFAULT_CODEGEN_MIGRATION_PLUGINS,
|
|
72
71
|
extra_context: dict[str, Any] | None = None,
|
|
73
|
-
):
|
|
74
|
-
...
|
|
72
|
+
): ...
|
|
75
73
|
|
|
76
74
|
|
|
77
75
|
def generate_code_for_versioned_packages(
|
cadwyn/route_generation.py
CHANGED
|
@@ -95,8 +95,7 @@ class InternalRepresentationOf:
|
|
|
95
95
|
def generate_versioned_routers(
|
|
96
96
|
router: _R,
|
|
97
97
|
versions: VersionBundle,
|
|
98
|
-
) -> dict[VersionDate, _R]:
|
|
99
|
-
...
|
|
98
|
+
) -> dict[VersionDate, _R]: ...
|
|
100
99
|
|
|
101
100
|
|
|
102
101
|
@overload
|
|
@@ -105,8 +104,7 @@ def generate_versioned_routers(
|
|
|
105
104
|
router: _R,
|
|
106
105
|
versions: VersionBundle,
|
|
107
106
|
latest_schemas_package: ModuleType | None,
|
|
108
|
-
) -> dict[VersionDate, _R]:
|
|
109
|
-
...
|
|
107
|
+
) -> dict[VersionDate, _R]: ...
|
|
110
108
|
|
|
111
109
|
|
|
112
110
|
def generate_versioned_routers(
|
cadwyn/routing.py
CHANGED
|
@@ -67,15 +67,14 @@ class _RootHeaderAPIRouter(APIRouter):
|
|
|
67
67
|
if self.min_routes_version > request_header_value:
|
|
68
68
|
# then the request version is older that the oldest route we have
|
|
69
69
|
_logger.info(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
f"version {self.min_routes_version.isoformat()} ",
|
|
70
|
+
"Request version is older than the oldest version. No route can match this version",
|
|
71
|
+
extra={"oldest_version": self.min_routes_version.isoformat(), "request_version": request_version},
|
|
73
72
|
)
|
|
74
73
|
return []
|
|
75
74
|
version_chosen = self.find_closest_date_but_not_new(request_header_value)
|
|
76
75
|
_logger.info(
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
"Partial match. The endpoint with a lower version was selected for the API call",
|
|
77
|
+
extra={"version_chosen": version_chosen, "request_version": request_version},
|
|
79
78
|
)
|
|
80
79
|
return self.versioned_routers[version_chosen].routes
|
|
81
80
|
|
cadwyn/structure/data.py
CHANGED
|
@@ -109,13 +109,11 @@ class AlterRequestByPathInstruction(_BaseAlterRequestInstruction):
|
|
|
109
109
|
@overload
|
|
110
110
|
def convert_request_to_next_version_for(
|
|
111
111
|
first_schema: type, /, *additional_schemas: type
|
|
112
|
-
) -> "type[staticmethod[_P, None]]":
|
|
113
|
-
...
|
|
112
|
+
) -> "type[staticmethod[_P, None]]": ...
|
|
114
113
|
|
|
115
114
|
|
|
116
115
|
@overload
|
|
117
|
-
def convert_request_to_next_version_for(path: str, methods: list[str], /) -> "type[staticmethod[_P, None]]":
|
|
118
|
-
...
|
|
116
|
+
def convert_request_to_next_version_for(path: str, methods: list[str], /) -> "type[staticmethod[_P, None]]": ...
|
|
119
117
|
|
|
120
118
|
|
|
121
119
|
def convert_request_to_next_version_for(
|
|
@@ -174,8 +172,7 @@ def convert_response_to_previous_version_for(
|
|
|
174
172
|
/,
|
|
175
173
|
*schemas: type,
|
|
176
174
|
migrate_http_errors: bool = False,
|
|
177
|
-
) -> "type[staticmethod[_P, None]]":
|
|
178
|
-
...
|
|
175
|
+
) -> "type[staticmethod[_P, None]]": ...
|
|
179
176
|
|
|
180
177
|
|
|
181
178
|
@overload
|
|
@@ -185,8 +182,7 @@ def convert_response_to_previous_version_for(
|
|
|
185
182
|
/,
|
|
186
183
|
*,
|
|
187
184
|
migrate_http_errors: bool = False,
|
|
188
|
-
) -> "type[staticmethod[_P, None]]":
|
|
189
|
-
...
|
|
185
|
+
) -> "type[staticmethod[_P, None]]": ...
|
|
190
186
|
|
|
191
187
|
|
|
192
188
|
def convert_response_to_previous_version_for(
|
cadwyn/structure/versions.py
CHANGED
|
@@ -20,7 +20,7 @@ from fastapi.concurrency import run_in_threadpool
|
|
|
20
20
|
from fastapi.dependencies.models import Dependant
|
|
21
21
|
from fastapi.dependencies.utils import solve_dependencies
|
|
22
22
|
from fastapi.exceptions import RequestValidationError
|
|
23
|
-
from fastapi.responses import FileResponse, StreamingResponse
|
|
23
|
+
from fastapi.responses import FileResponse, JSONResponse, StreamingResponse
|
|
24
24
|
from fastapi.routing import APIRoute, _prepare_response_content
|
|
25
25
|
from pydantic import BaseModel
|
|
26
26
|
from starlette._utils import is_async_callable
|
|
@@ -74,9 +74,9 @@ class VersionChange:
|
|
|
74
74
|
alter_enum_instructions: ClassVar[list[AlterEnumSubInstruction]] = Sentinel
|
|
75
75
|
alter_module_instructions: ClassVar[list[AlterModuleInstruction]] = Sentinel
|
|
76
76
|
alter_endpoint_instructions: ClassVar[list[AlterEndpointSubInstruction]] = Sentinel
|
|
77
|
-
alter_request_by_schema_instructions: ClassVar[
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
alter_request_by_schema_instructions: ClassVar[dict[type[BaseModel], list[AlterRequestBySchemaInstruction]]] = (
|
|
78
|
+
Sentinel
|
|
79
|
+
)
|
|
80
80
|
alter_request_by_path_instructions: ClassVar[dict[str, list[AlterRequestByPathInstruction]]] = Sentinel
|
|
81
81
|
alter_response_by_schema_instructions: ClassVar[dict[type, list[AlterResponseBySchemaInstruction]]] = Sentinel
|
|
82
82
|
alter_response_by_path_instructions: ClassVar[dict[str, list[AlterResponseByPathInstruction]]] = Sentinel
|
|
@@ -245,8 +245,7 @@ class VersionBundle:
|
|
|
245
245
|
*other_versions: Version,
|
|
246
246
|
api_version_var: APIVersionVarType | None = None,
|
|
247
247
|
head_schemas_package: ModuleType | None = None,
|
|
248
|
-
) -> None:
|
|
249
|
-
...
|
|
248
|
+
) -> None: ...
|
|
250
249
|
|
|
251
250
|
@overload
|
|
252
251
|
@deprecated("Pass head_version_package instead of latest_schemas_package.")
|
|
@@ -257,8 +256,7 @@ class VersionBundle:
|
|
|
257
256
|
*other_versions: Version,
|
|
258
257
|
api_version_var: APIVersionVarType | None = None,
|
|
259
258
|
latest_schemas_package: ModuleType | None = None,
|
|
260
|
-
) -> None:
|
|
261
|
-
...
|
|
259
|
+
) -> None: ...
|
|
262
260
|
|
|
263
261
|
def __init__(
|
|
264
262
|
self,
|
|
@@ -620,7 +618,10 @@ class VersionBundle:
|
|
|
620
618
|
if isinstance(response_or_response_body, StreamingResponse | FileResponse):
|
|
621
619
|
body = None
|
|
622
620
|
elif response_or_response_body.body:
|
|
623
|
-
|
|
621
|
+
if isinstance(response_or_response_body, JSONResponse) or raised_exception is not None:
|
|
622
|
+
body = json.loads(response_or_response_body.body)
|
|
623
|
+
else:
|
|
624
|
+
body = response_or_response_body.body.decode(response_or_response_body.charset)
|
|
624
625
|
else:
|
|
625
626
|
body = None
|
|
626
627
|
# TODO (https://github.com/zmievsa/cadwyn/issues/51): Only do this if there are migrations
|
|
@@ -666,16 +667,25 @@ class VersionBundle:
|
|
|
666
667
|
# that do not have it. We don't support it too.
|
|
667
668
|
if response_info.body is not None and hasattr(response_info._response, "body"):
|
|
668
669
|
# TODO (https://github.com/zmievsa/cadwyn/issues/51): Only do this if there are migrations
|
|
669
|
-
|
|
670
|
+
if isinstance(response_info.body, str):
|
|
671
|
+
response_info._response.body = response_info.body.encode(response_info._response.charset)
|
|
672
|
+
else:
|
|
673
|
+
response_info._response.body = json.dumps(
|
|
674
|
+
response_info.body,
|
|
675
|
+
ensure_ascii=False,
|
|
676
|
+
allow_nan=False,
|
|
677
|
+
indent=None,
|
|
678
|
+
separators=(",", ":"),
|
|
679
|
+
).encode("utf-8")
|
|
680
|
+
# It makes sense to re-calculate content length because the previously calculated one
|
|
681
|
+
# might slightly differ. If it differs -- uvicorn will break.
|
|
682
|
+
response_info.headers["content-length"] = str(len(response_info._response.body))
|
|
670
683
|
|
|
671
684
|
if raised_exception is not None and response_info.status_code >= 400:
|
|
672
685
|
if isinstance(response_info.body, dict) and "detail" in response_info.body:
|
|
673
686
|
detail = response_info.body["detail"]
|
|
674
687
|
else:
|
|
675
688
|
detail = response_info.body
|
|
676
|
-
# It makes more sense to re-calculate content length because the previously calculated one
|
|
677
|
-
# might slightly differ.
|
|
678
|
-
del response_info.headers["content-length"]
|
|
679
689
|
|
|
680
690
|
raise HTTPException(
|
|
681
691
|
status_code=response_info.status_code,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cadwyn/__init__.py,sha256=XgF-CtZo-fPk5730sKlY2fAmPsTQRIsFbrfNFeUZyFY,495
|
|
2
|
-
cadwyn/__main__.py,sha256=
|
|
2
|
+
cadwyn/__main__.py,sha256=q7oNhnJ_hNRib3o6cAo4QC0cME0prVi-6P0G14tRdkw,4339
|
|
3
3
|
cadwyn/_asts.py,sha256=S-x9fVKTENZZxwWfabm0PbztcHyX2MJkI6Cwv5XgVrI,10138
|
|
4
4
|
cadwyn/_compat.py,sha256=6QwtzbXn53mIhEFfEizmFjd-f894oLsM6ITxqq2rCpc,5408
|
|
5
5
|
cadwyn/_package_utils.py,sha256=trxTYLmppv-10SKhScfyDQJh21rsQGFoLaOtHycKKR0,1443
|
|
@@ -8,7 +8,7 @@ cadwyn/applications.py,sha256=MAVsgYojgQO4PrUETVMAsp49k6baW4h4LtS6z12gTZs,15767
|
|
|
8
8
|
cadwyn/codegen/README.md,sha256=hc7AE87LsEsvbh-wX1H10JEWh-8bLHoe-1CkY3h00FI,879
|
|
9
9
|
cadwyn/codegen/__init__.py,sha256=JgddDjxMTjSfVrMXHwNu1ODgdn2QfPWpccrRKquBV6k,355
|
|
10
10
|
cadwyn/codegen/_common.py,sha256=FTI4fqpUFGBMACVlPiDMHTWhqwW_-zQNa_4Qh7m-hCA,5877
|
|
11
|
-
cadwyn/codegen/_main.py,sha256=
|
|
11
|
+
cadwyn/codegen/_main.py,sha256=1mpXq_1AuZaAOeGjrCVMhcK7zhjmmlO82Q3ehoOOAfM,10483
|
|
12
12
|
cadwyn/codegen/_plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
cadwyn/codegen/_plugins/class_migrations.py,sha256=kHZ-RMRTARZ4l70fxHMtul_204Ute2_yQmEej7wMwwo,20119
|
|
14
14
|
cadwyn/codegen/_plugins/class_rebuilding.py,sha256=zNlB_VxoEAtdC5Ydiqa7pu6Ka-pKnpPQk_dvovaK0QI,3623
|
|
@@ -19,20 +19,20 @@ cadwyn/exceptions.py,sha256=gsb1vszQ2VsnfTBM5B8AYmXwCW0yvA8pJ1GhNkGzgyE,1440
|
|
|
19
19
|
cadwyn/main.py,sha256=kt2Vn7TIA4ZnD_xrgz57TOjUk-4zVP8SV8nuTZBEaaU,218
|
|
20
20
|
cadwyn/middleware.py,sha256=8cuBri_yRkl0goe6G0MLwtL04WGbW9Infah3wy9hUVM,3372
|
|
21
21
|
cadwyn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
cadwyn/route_generation.py,sha256=
|
|
23
|
-
cadwyn/routing.py,sha256=
|
|
22
|
+
cadwyn/route_generation.py,sha256=veFSg4xlInZaJzlcO6gr3wfUCbU0_TFeU3e-9HTiqLY,35696
|
|
23
|
+
cadwyn/routing.py,sha256=ObH4-ETYPQjm3bMVCNzGttEKv1LL9q2sbi9eJD4W3lY,6250
|
|
24
24
|
cadwyn/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
cadwyn/static/docs.html,sha256=WNm5ANJVy51TcIUFOaqKf1Z8eF86CC85TTHPxACtkzw,3455
|
|
26
26
|
cadwyn/structure/__init__.py,sha256=HjaNd6H4m4Cia42-dCO7A7sLWuVII7oldjaCabhbs_o,697
|
|
27
27
|
cadwyn/structure/common.py,sha256=6Z4nI97XPWTCinn6np73m-rLPyYNrz2fWXKJlqjsiaQ,269
|
|
28
|
-
cadwyn/structure/data.py,sha256=
|
|
28
|
+
cadwyn/structure/data.py,sha256=161UO_Y669-dKdSvBx5zHT7SorppApT_VXUtideFyjs,7112
|
|
29
29
|
cadwyn/structure/endpoints.py,sha256=VngfAydGBwekhV2tBOtNDPVgl3X1IgYxUCw--VZ5cQY,5627
|
|
30
30
|
cadwyn/structure/enums.py,sha256=iMokxA2QYJ61SzyB-Pmuq3y7KL7-e6TsnjLVUaVZQnw,954
|
|
31
31
|
cadwyn/structure/modules.py,sha256=1FK-lLm-zOTXEvn-QtyBH38aDRht5PDQiZrOPCsBlM4,1268
|
|
32
32
|
cadwyn/structure/schemas.py,sha256=0ylArAkUw626VkUOJSulOwJs7CS6lrGBRECEG5HFD4Q,8897
|
|
33
|
-
cadwyn/structure/versions.py,sha256=
|
|
34
|
-
cadwyn-3.12.
|
|
35
|
-
cadwyn-3.12.
|
|
36
|
-
cadwyn-3.12.
|
|
37
|
-
cadwyn-3.12.
|
|
38
|
-
cadwyn-3.12.
|
|
33
|
+
cadwyn/structure/versions.py,sha256=qSUOs0-jmWuOMaDMac_EBPtuaJktdChGLuUabjopQPc,36902
|
|
34
|
+
cadwyn-3.12.1.dist-info/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
|
|
35
|
+
cadwyn-3.12.1.dist-info/METADATA,sha256=V7wUTcOuVwl67QOKynW5LBZw1inrKSxwp6XFdqfuGC8,4360
|
|
36
|
+
cadwyn-3.12.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
37
|
+
cadwyn-3.12.1.dist-info/entry_points.txt,sha256=eO05hLn9GoRzzpwT9GONPmXKsonjuMNssM2D2WHWKGk,46
|
|
38
|
+
cadwyn-3.12.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|