Skip to content

Commit 45c0c1e

Browse files
authored
Fix typing_extensions==3.14.0 errors on import (#284)
1 parent cecb54e commit 45c0c1e

File tree

4 files changed

+844
-810
lines changed

4 files changed

+844
-810
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Please follow [the Keep a Changelog standard](https://keepachangelog.com/en/1.0.
55

66
## [Unreleased]
77

8+
## [5.4.1]
9+
10+
### Fixed
11+
12+
* Fixed import error in python 3.9 when using typing_extensions==3.14.0
13+
814
## [5.4.0]
915

1016
### Added

cadwyn/schema_generation.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
from datetime import date
1212
from enum import Enum
1313
from functools import cache
14-
from typing import TYPE_CHECKING, Annotated, Generic, Union, cast
14+
from typing import (
15+
TYPE_CHECKING,
16+
Annotated,
17+
Generic,
18+
Union,
19+
_BaseGenericAlias, # pyright: ignore[reportAttributeAccessIssue]
20+
cast,
21+
)
1522

1623
import fastapi.params
1724
import fastapi.security.base
@@ -79,11 +86,6 @@
7986
from cadwyn.structure.versions import HeadVersion, Version, VersionBundle
8087

8188

82-
if sys.version_info >= (3, 10):
83-
from typing import _BaseGenericAlias # pyright: ignore[reportAttributeAccessIssue]
84-
else:
85-
from typing_extensions import _BaseGenericAlias # pyright: ignore[reportAttributeAccessIssue]
86-
8789
_Call = TypeVar("_Call", bound=Callable[..., Any])
8890

8991
_FieldName: TypeAlias = str
@@ -584,7 +586,7 @@ def migrate_route_to_version(self, route: fastapi.routing.APIRoute, *, ignore_re
584586
def _change_version_of_a_non_container_annotation(self, annotation: Any) -> Any:
585587
from typing_inspection.typing_objects import is_any, is_newtype, is_typealiastype
586588

587-
if isinstance(annotation, (_BaseGenericAlias, types.GenericAlias)):
589+
if isinstance(annotation, (types.GenericAlias, _BaseGenericAlias)):
588590
return get_origin(annotation)[tuple(self.change_version_of_annotation(arg) for arg in get_args(annotation))]
589591
elif is_typealiastype(annotation):
590592
if (

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.4.0"
3+
version = "5.4.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"

0 commit comments

Comments
 (0)