Skip to content

Commit f749553

Browse files
committed
Fix type alias with Python 3.8
See https://bugs.python.org/issue45117
1 parent 0ce87a1 commit f749553

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

aws_lambda_powertools/event_handler/openapi/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from enum import Enum
4-
from typing import Any, Literal
4+
from typing import Any, Literal, Union
55

66
from pydantic import AnyUrl, BaseModel, Field
77

@@ -181,7 +181,7 @@ class Schema(BaseModel):
181181

182182
# Ref: https://json-schema.org/draft/2020-12/json-schema-core.html#name-json-schema-documents
183183
# A JSON Schema MUST be an object or a boolean.
184-
SchemaOrBool = Schema | bool
184+
SchemaOrBool = Union[Schema, bool]
185185

186186

187187
# https://swagger.io/specification/#example-object
@@ -408,7 +408,7 @@ class OpenIdConnect(SecurityBase):
408408
openIdConnectUrl: str
409409

410410

411-
SecurityScheme = APIKey | HTTPBase | OAuth2 | OpenIdConnect | HTTPBearer
411+
SecurityScheme = Union[APIKey, HTTPBase, OAuth2, OpenIdConnect, HTTPBearer]
412412

413413

414414
# https://swagger.io/specification/#components-object

aws_lambda_powertools/event_handler/openapi/types.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
import types
44
from enum import Enum
5-
from typing import TYPE_CHECKING, Any, Callable, TypedDict, Union
5+
from typing import Any, Callable, Dict, Set, TypedDict, Union
66

7+
from pydantic import BaseModel
78
from typing_extensions import NotRequired
89

9-
if TYPE_CHECKING:
10-
from pydantic import BaseModel
11-
12-
CacheKey = Callable[..., Any] | None
13-
IncEx = set[int] | set[str] | dict[int, Any] | dict[str, Any]
14-
TypeModelOrEnum = type[BaseModel] | type[Enum]
15-
ModelNameMap = dict[TypeModelOrEnum, str]
10+
CacheKey = Union[Callable[..., Any], None]
11+
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]
12+
TypeModelOrEnum = Union[type[BaseModel], type[Enum]]
13+
ModelNameMap = Dict[TypeModelOrEnum, str]
1614
UnionType = getattr(types, "UnionType", Union)
1715

1816

0 commit comments

Comments
 (0)