cadwyn 5.1.2__py3-none-any.whl → 5.1.4__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/exceptions.py CHANGED
@@ -1,4 +1,3 @@
1
- import json
2
1
  from typing import Any
3
2
 
4
3
  from fastapi.routing import APIRoute
@@ -21,7 +20,7 @@ class CadwynHeadRequestValidationError(CadwynError):
21
20
  f"We failed to migrate the request with version={self.version}. "
22
21
  "This means that there is some error in your migrations or schema structure that makes it impossible "
23
22
  "to migrate the request of that version to latest.\n"
24
- f"body={self.body}\n\nerrors={json.dumps(self.errors, indent=4, ensure_ascii=False)}"
23
+ f"body={self.body}\n\nerrors={self.errors}"
25
24
  )
26
25
 
27
26
 
@@ -40,6 +40,7 @@ from typing_extensions import (
40
40
  NewType,
41
41
  Self,
42
42
  TypeAlias,
43
+ TypeAliasType,
43
44
  TypeVar,
44
45
  _AnnotatedAlias,
45
46
  assert_never,
@@ -100,6 +101,7 @@ PYDANTIC_DECORATOR_TYPE_TO_DECORATOR_MAP = {
100
101
  ModelSerializerDecoratorInfo: pydantic.model_serializer,
101
102
  ComputedFieldInfo: pydantic.computed_field,
102
103
  }
104
+ _PYDANTIC_ALL_EXPORTED_NAMES = set(pydantic.__all__)
103
105
 
104
106
 
105
107
  VALIDATOR_CONFIG_KEY = "__validators__"
@@ -580,6 +582,17 @@ class _AnnotationTransformer:
580
582
  def _change_version_of_a_non_container_annotation(self, annotation: Any) -> Any:
581
583
  if isinstance(annotation, (_BaseGenericAlias, types.GenericAlias)):
582
584
  return get_origin(annotation)[tuple(self.change_version_of_annotation(arg) for arg in get_args(annotation))]
585
+ elif isinstance(annotation, TypeAliasType):
586
+ if (
587
+ annotation.__module__ is not None and (annotation.__module__.startswith("pydantic."))
588
+ ) or annotation.__name__ in _PYDANTIC_ALL_EXPORTED_NAMES:
589
+ return annotation
590
+ else:
591
+ return TypeAliasType( # pyright: ignore[reportGeneralTypeIssues]
592
+ name=annotation.__name__,
593
+ value=self.change_version_of_annotation(annotation.__value__),
594
+ type_params=self.change_version_of_annotation(annotation.__type_params__),
595
+ )
583
596
  elif isinstance(annotation, fastapi.params.Security):
584
597
  return fastapi.params.Security(
585
598
  self.change_version_of_annotation(annotation.dependency),
@@ -1079,6 +1092,7 @@ class _EnumWrapper(Generic[_T_ENUM]):
1079
1092
  initialization_namespace = self._get_initialization_namespace_for_enum(self.cls) | raw_member_map
1080
1093
  for attr_name, attr in initialization_namespace.items():
1081
1094
  enum_dict[attr_name] = attr
1095
+ enum_dict["__doc__"] = self.cls.__doc__
1082
1096
  model_copy = cast(type[_T_ENUM], type(self.name, self.cls.__bases__, enum_dict))
1083
1097
  model_copy.__cadwyn_original_model__ = self.cls # pyright: ignore[reportAttributeAccessIssue]
1084
1098
  return model_copy
@@ -1,5 +1,6 @@
1
1
  import email.message
2
2
  import functools
3
+ import http
3
4
  import inspect
4
5
  import json
5
6
  from collections import defaultdict
@@ -8,7 +9,7 @@ from contextlib import AsyncExitStack
8
9
  from contextvars import ContextVar
9
10
  from datetime import date
10
11
  from enum import Enum
11
- from typing import TYPE_CHECKING, ClassVar, Union
12
+ from typing import TYPE_CHECKING, ClassVar, Union, cast
12
13
 
13
14
  from fastapi import BackgroundTasks, HTTPException, params
14
15
  from fastapi import Request as FastapiRequest
@@ -616,12 +617,13 @@ class VersionBundle:
616
617
  detail = response_info.body["detail"]
617
618
  else:
618
619
  detail = response_info.body
620
+ if detail is None:
621
+ detail = http.HTTPStatus(response_info.status_code).phrase
622
+ raised_exception.detail = cast(str, detail)
623
+ raised_exception.headers = dict(response_info.headers)
624
+ raised_exception.status_code = response_info.status_code
619
625
 
620
- raise HTTPException(
621
- status_code=response_info.status_code,
622
- detail=detail,
623
- headers=dict(response_info.headers),
624
- )
626
+ raise raised_exception
625
627
  return response_info._response
626
628
  return response_info.body
627
629
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cadwyn
3
- Version: 5.1.2
3
+ Version: 5.1.4
4
4
  Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
5
5
  Project-URL: Source code, https://github.com/zmievsa/cadwyn
6
6
  Project-URL: Documentation, https://docs.cadwyn.dev
@@ -35,7 +35,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
35
35
  Classifier: Typing :: Typed
36
36
  Requires-Python: >=3.9
37
37
  Requires-Dist: backports-strenum<2,>=1.3.1; python_version < '3.11'
38
- Requires-Dist: fastapi>=0.112.3
38
+ Requires-Dist: fastapi>=0.112.4
39
39
  Requires-Dist: issubclass>=0.1.2
40
40
  Requires-Dist: jinja2>=3.1.2
41
41
  Requires-Dist: pydantic>=2.0.0
@@ -7,12 +7,12 @@ cadwyn/_utils.py,sha256=q_mTtMKTNTDzqCza67XST-jaPSfuTgnFLmOe0dlGeYY,2295
7
7
  cadwyn/applications.py,sha256=YyESoMwQMq9jxqai6lNrsL0BAKxjTKW5lm3Se_U81j4,20391
8
8
  cadwyn/changelogs.py,sha256=aBTlsZ8PQpw9t4sSyezNTYDs6CMPtzIGulgAHA1ELPs,19622
9
9
  cadwyn/dependencies.py,sha256=9JihGg7MPbP0oBFRWebvIzhh6B-oYqd1EYNjB-OZqpw,241
10
- cadwyn/exceptions.py,sha256=gLCikeUPeLJwVjM8_DoSTIFHwmNI7n7vw1atpgHvbMU,1803
10
+ cadwyn/exceptions.py,sha256=8D1G7ewLrMF5jq7leald1g0ulcH9zQl8ufEK3b7HHAE,1749
11
11
  cadwyn/middleware.py,sha256=jtcysj66Fck_3EteK0zLJCOTMms3g6avi3U8lV-roQI,4316
12
12
  cadwyn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  cadwyn/route_generation.py,sha256=e7mnVqtvTx1Oh_khmrM0dAowhVUOO1K4vaVVEGgXgrY,25230
14
14
  cadwyn/routing.py,sha256=EkV38cDQFAtR1M_fGWeq81lYaSPuDK4Pr8fjTTJVZvY,6912
15
- cadwyn/schema_generation.py,sha256=QrOH8WKUbaQs6ztXkHf1hGb6VLEJOS794bYx4G9lx8k,46113
15
+ cadwyn/schema_generation.py,sha256=QK_G-G56S1brGTSpEGEE77tbifSi7IzwNK1oiVfMkPA,46850
16
16
  cadwyn/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  cadwyn/static/docs.html,sha256=WNm5ANJVy51TcIUFOaqKf1Z8eF86CC85TTHPxACtkzw,3455
18
18
  cadwyn/structure/__init__.py,sha256=Wgvjdq3vfl9Yhe-BkcFGAMi_Co11YOfTmJQqgF5Gzx4,655
@@ -21,9 +21,9 @@ cadwyn/structure/data.py,sha256=NWURVnP_84VI2ugp9ppo0Ofyve3pVYjymF9K82Jh-SA,7791
21
21
  cadwyn/structure/endpoints.py,sha256=zUgzglNhBPnmWdJ03A8pFT4zPs_lj8nQ7c7Uo2d-ejU,6246
22
22
  cadwyn/structure/enums.py,sha256=4FCc9aniLE3VuWAVIacrNP_FWxTIUm9JkeeHA_zZdwQ,1254
23
23
  cadwyn/structure/schemas.py,sha256=80AUbko1cksXh7qPBmnknDFLK52xr4kw9HfHeXqcw1I,10813
24
- cadwyn/structure/versions.py,sha256=PrWA2m-81b7LuYqrmaaEr-LhQ54nXz7sSe_-WKb-9g0,34271
25
- cadwyn-5.1.2.dist-info/METADATA,sha256=MXBoDEfZl0sej1hR4F8VsiJ5RP9wzf81iFFSLmNbWkM,4562
26
- cadwyn-5.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- cadwyn-5.1.2.dist-info/entry_points.txt,sha256=mGX8wl-Xfhpr5M93SUmkykaqinUaYAvW9rtDSX54gx0,47
28
- cadwyn-5.1.2.dist-info/licenses/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
29
- cadwyn-5.1.2.dist-info/RECORD,,
24
+ cadwyn/structure/versions.py,sha256=eEF5FUrao3bYd-OiZeyG0fkozuThRqhW7sEzRNhdsfQ,34440
25
+ cadwyn-5.1.4.dist-info/METADATA,sha256=dERQ0uTzbqFX717Khya0WEEXeDXWEe7fI6x_O0QS1Zk,4562
26
+ cadwyn-5.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ cadwyn-5.1.4.dist-info/entry_points.txt,sha256=mGX8wl-Xfhpr5M93SUmkykaqinUaYAvW9rtDSX54gx0,47
28
+ cadwyn-5.1.4.dist-info/licenses/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
29
+ cadwyn-5.1.4.dist-info/RECORD,,
File without changes