Skip to content

Commit ebe1792

Browse files
committed
Remove memoization from schema generation to fix a bug in airflow
1 parent bc75ed5 commit ebe1792

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

cadwyn/schema_generation.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,7 @@ async def __call__(self, *args: Any, **kwargs: Any):
540540
@final
541541
class _AnnotationTransformer:
542542
def __init__(self, generator: "SchemaGenerator") -> None:
543-
# This cache is not here for speeding things up. It's for preventing the creation of copies of the same object
544-
# because such copies could produce weird behaviors at runtime, especially if you/FastAPI do any comparisons.
545-
# It's defined here and not on the method because of this: https://youtu.be/sVjtp6tGo0g
546543
self.generator = generator
547-
# TODO: Rewrite this to memoize
548-
self.change_versions_of_a_non_container_annotation = functools.cache(
549-
self._change_version_of_a_non_container_annotation
550-
)
551544

552545
def change_version_of_annotation(self, annotation: Any) -> Any:
553546
"""Recursively go through all annotations and change them to annotations corresponding to the version passed.
@@ -565,7 +558,7 @@ def change_version_of_annotation(self, annotation: Any) -> Any:
565558
elif isinstance(annotation, (list, tuple)):
566559
return type(annotation)(self.change_version_of_annotation(v) for v in annotation)
567560
else:
568-
return self.change_versions_of_a_non_container_annotation(annotation)
561+
return self._change_version_of_a_non_container_annotation(annotation)
569562

570563
def migrate_router_to_version(self, router: fastapi.routing.APIRouter):
571564
for route in router.routes:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cadwyn"
3-
version = "5.5.0"
3+
version = "5.5.1"
44
description = "Production-ready community-driven modern Stripe-like API versioning in FastAPI"
55
authors = [{ name = "Stanislav Zmiev", email = "zmievsa@gmail.com" }]
66
license = "MIT"

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)