cadwyn 3.6.1__tar.gz → 3.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.

Potentially problematic release.


This version of cadwyn might be problematic. Click here for more details.

Files changed (34) hide show
  1. {cadwyn-3.6.1 → cadwyn-3.6.3}/PKG-INFO +3 -3
  2. {cadwyn-3.6.1 → cadwyn-3.6.3}/README.md +2 -2
  3. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/applications.py +3 -4
  4. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_common.py +7 -3
  5. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_main.py +2 -0
  6. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/class_migrations.py +4 -4
  7. {cadwyn-3.6.1 → cadwyn-3.6.3}/pyproject.toml +8 -9
  8. {cadwyn-3.6.1 → cadwyn-3.6.3}/LICENSE +0 -0
  9. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/__init__.py +0 -0
  10. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/__main__.py +0 -0
  11. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/_asts.py +0 -0
  12. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/_compat.py +0 -0
  13. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/_package_utils.py +0 -0
  14. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/_utils.py +0 -0
  15. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/README.md +0 -0
  16. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/__init__.py +0 -0
  17. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/__init__.py +0 -0
  18. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/class_rebuilding.py +0 -0
  19. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/class_renaming.py +0 -0
  20. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/import_auto_adding.py +0 -0
  21. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/latest_version_aliasing.py +0 -0
  22. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/codegen/_plugins/module_migrations.py +0 -0
  23. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/exceptions.py +0 -0
  24. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/main.py +0 -0
  25. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/py.typed +0 -0
  26. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/routing.py +0 -0
  27. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/__init__.py +0 -0
  28. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/common.py +0 -0
  29. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/data.py +0 -0
  30. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/endpoints.py +0 -0
  31. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/enums.py +0 -0
  32. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/modules.py +0 -0
  33. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/schemas.py +0 -0
  34. {cadwyn-3.6.1 → cadwyn-3.6.3}/cadwyn/structure/versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cadwyn
3
- Version: 3.6.1
3
+ Version: 3.6.3
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
@@ -49,8 +49,8 @@ Production-ready community-driven modern [Stripe-like](https://stripe.com/blog/a
49
49
  ---
50
50
 
51
51
  <p align="center">
52
- <a href="https://github.com/zmievsa/cadwyn/actions?query=workflow%3ATests+event%3Apush+branch%3Amain" target="_blank">
53
- <img src="https://github.com/zmievsa/cadwyn/actions/workflows/test.yaml/badge.svg?branch=main&event=push" alt="Test">
52
+ <a href="https://github.com/zmievsa/cadwyn/actions/workflows/ci.yaml?branch=main&event=push" target="_blank">
53
+ <img src="https://github.com/zmievsa/cadwyn/actions/workflows/ci.yaml/badge.svg?branch=main&event=push" alt="Test">
54
54
  </a>
55
55
  <a href="https://codecov.io/gh/ovsyanka83/cadwyn" target="_blank">
56
56
  <img src="https://img.shields.io/codecov/c/github/ovsyanka83/cadwyn?color=%2334D058" alt="Coverage">
@@ -5,8 +5,8 @@ Production-ready community-driven modern [Stripe-like](https://stripe.com/blog/a
5
5
  ---
6
6
 
7
7
  <p align="center">
8
- <a href="https://github.com/zmievsa/cadwyn/actions?query=workflow%3ATests+event%3Apush+branch%3Amain" target="_blank">
9
- <img src="https://github.com/zmievsa/cadwyn/actions/workflows/test.yaml/badge.svg?branch=main&event=push" alt="Test">
8
+ <a href="https://github.com/zmievsa/cadwyn/actions/workflows/ci.yaml?branch=main&event=push" target="_blank">
9
+ <img src="https://github.com/zmievsa/cadwyn/actions/workflows/ci.yaml/badge.svg?branch=main&event=push" alt="Test">
10
10
  </a>
11
11
  <a href="https://codecov.io/gh/ovsyanka83/cadwyn" target="_blank">
12
12
  <img src="https://img.shields.io/codecov/c/github/ovsyanka83/cadwyn?color=%2334D058" alt="Coverage">
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Callable, Coroutine, Sequence
2
2
  from types import ModuleType
3
- from typing import TYPE_CHECKING, Any, cast
3
+ from typing import Any, cast
4
4
 
5
5
  from fastapi import APIRouter, routing
6
6
  from fastapi.datastructures import Default
@@ -14,7 +14,6 @@ from starlette.types import Lifespan
14
14
  from typing_extensions import Self
15
15
  from verselect import HeaderRoutingFastAPI
16
16
 
17
- from cadwyn.exceptions import CadwynError
18
17
  from cadwyn.routing import generate_versioned_routers
19
18
  from cadwyn.structure import VersionBundle
20
19
 
@@ -62,11 +61,11 @@ class Cadwyn(HeaderRoutingFastAPI):
62
61
  separate_input_output_schemas: bool = True,
63
62
  **extra: Any,
64
63
  ) -> None:
64
+ self.versions = versions
65
65
  # TODO: Remove argument entirely in any major version.
66
66
  latest_schemas_package = extra.pop("latest_schemas_package", None) or self.versions.latest_schemas_package
67
- self.latest_schemas_package = cast(ModuleType, latest_schemas_package)
68
67
  self.versions.latest_schemas_package = latest_schemas_package
69
- self.versions = versions
68
+ self.latest_schemas_package = cast(ModuleType, latest_schemas_package)
70
69
 
71
70
  super().__init__(
72
71
  api_version_header_name=api_version_header_name,
@@ -30,8 +30,12 @@ class PydanticModelWrapper:
30
30
  name: str
31
31
  fields: dict[_FieldName, PydanticFieldWrapper]
32
32
  validators: dict[_FieldName, _ValidatorWrapper]
33
+ annotations: dict[str, Any] = dataclasses.field(init=False, repr=False)
33
34
  _parents: list[Self] | None = dataclasses.field(init=False, default=None)
34
35
 
36
+ def __post_init__(self):
37
+ self.annotations = self.cls.__annotations__.copy()
38
+
35
39
  def _get_parents(self, schemas: "dict[IdentifierPythonPath, Self]"):
36
40
  if self._parents is not None:
37
41
  return self._parents
@@ -61,9 +65,9 @@ class PydanticModelWrapper:
61
65
  annotations = {}
62
66
 
63
67
  for parent in reversed(self._get_parents(schemas)):
64
- annotations |= parent.cls.__annotations__
68
+ annotations |= parent.annotations
65
69
 
66
- return annotations | self.cls.__annotations__
70
+ return annotations | self.annotations
67
71
 
68
72
 
69
73
  @cache
@@ -76,7 +80,7 @@ def get_fields_and_validators_from_model(
76
80
  fields = model_fields(cls)
77
81
  try:
78
82
  source = inspect.getsource(cls)
79
- except OSError:
83
+ except OSError: # pragma: no cover # It is covered by tests but not on every platform
80
84
  return (
81
85
  {
82
86
  field_name: PydanticFieldWrapper(annotation=field.annotation, init_model_field=field)
@@ -81,6 +81,8 @@ def generate_code_for_versioned_packages(
81
81
  codegen_plugins=codegen_plugins,
82
82
  migration_plugins=migration_plugins,
83
83
  )
84
+ # This should not affect real use cases at all but is rather useful for testing
85
+ importlib.invalidate_caches()
84
86
 
85
87
 
86
88
  def _generate_versioned_directories(
@@ -156,7 +156,7 @@ def _add_field_to_model(
156
156
  for attr_name, attr_value in passed_field_attributes.items():
157
157
  add_keyword_to_call(attr_name, attr_value, field_call_ast)
158
158
  field.value_ast = field_call_ast
159
- model.cls.__annotations__[alter_schema_instruction.name] = alter_schema_instruction.type
159
+ model.annotations[alter_schema_instruction.name] = alter_schema_instruction.type
160
160
 
161
161
 
162
162
  def _change_field_in_model(
@@ -175,7 +175,7 @@ def _change_field_in_model(
175
175
 
176
176
  field = defined_fields[alter_schema_instruction.name]
177
177
  model.fields[alter_schema_instruction.name] = field
178
- model.cls.__annotations__[alter_schema_instruction.name] = defined_annotations[alter_schema_instruction.name]
178
+ model.annotations[alter_schema_instruction.name] = defined_annotations[alter_schema_instruction.name]
179
179
 
180
180
  annotation_ast, field_call_ast, contype_is_definitely_used = _get_constraint_asts_and_field_call_ast(
181
181
  schemas, model, alter_schema_instruction.name, field
@@ -247,7 +247,7 @@ def _change_field( # noqa: C901
247
247
  f'but it already has type "{field.annotation}"',
248
248
  )
249
249
  field.annotation = alter_schema_instruction.type
250
- model.cls.__annotations__[alter_schema_instruction.name] = alter_schema_instruction.type
250
+ model.annotations[alter_schema_instruction.name] = alter_schema_instruction.type
251
251
  fancy_type_repr = get_fancy_repr(alter_schema_instruction.type)
252
252
  field.annotation_ast = ast.parse(fancy_type_repr, mode="eval").body
253
253
 
@@ -259,7 +259,7 @@ def _change_field( # noqa: C901
259
259
  "but it already has that name.",
260
260
  )
261
261
  model.fields[alter_schema_instruction.new_name] = model.fields.pop(alter_schema_instruction.name)
262
- model.cls.__annotations__[alter_schema_instruction.new_name] = model.cls.__annotations__.pop(
262
+ model.annotations[alter_schema_instruction.new_name] = model.annotations.pop(
263
263
  alter_schema_instruction.name,
264
264
  defined_annotations[alter_schema_instruction.name],
265
265
  )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cadwyn"
3
- version = "3.6.1"
3
+ version = "3.6.3"
4
4
  description = "Production-ready community-driven modern Stripe-like API versioning in FastAPI"
5
5
  authors = ["Stanislav Zmiev <zmievsa@gmail.com>"]
6
6
  license = "MIT"
@@ -69,15 +69,14 @@ pytest-cov = ">=4.0.0"
69
69
  uvicorn = "*"
70
70
  devtools = "*"
71
71
  pdbpp = "^0.10.3"
72
- pytest-asyncio = "^0.21.0"
73
72
  httpx = "*"
74
- pytest-fixture-classes = "^1.0.3"
75
- pre-commit = "^3.4.0"
76
- dirty-equals = "^0.6.0"
77
- mkdocs = "^1.5.2"
78
- mkdocs-material = "^9.3.1"
79
- python-multipart = "^0.0.6"
80
- mkdocs-simple-hooks = "^0.1.5"
73
+ pytest-fixture-classes = ">=1.0.3"
74
+ pre-commit = ">=3.4.0"
75
+ dirty-equals = ">=0.6.0"
76
+ mkdocs = ">=1.5.2"
77
+ mkdocs-material = ">=9.3.1"
78
+ python-multipart = ">=0.0.6"
79
+ mkdocs-simple-hooks = ">=0.1.5"
81
80
 
82
81
  [tool.poetry.scripts]
83
82
  cadwyn = "cadwyn.__main__:app"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes