Skip to content

Commit 9e49558

Browse files
committed
refactor(typing): move more types into TYPE_CHECKING
1 parent 69cd4d2 commit 9e49558

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

aws_lambda_powertools/event_handler/openapi/compat.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@
1010

1111
from dataclasses import dataclass, is_dataclass
1212
from enum import Enum
13-
from typing import Any, Deque, FrozenSet, List, Mapping, Sequence, Set, Tuple, Union
13+
from typing import TYPE_CHECKING, Any, Deque, FrozenSet, List, Mapping, Sequence, Set, Tuple, Union
1414

1515
from typing_extensions import Annotated, Literal, get_origin, get_args
1616

1717
from pydantic import BaseModel, create_model
1818
from pydantic.fields import FieldInfo
1919

20-
from aws_lambda_powertools.event_handler.openapi.types import (
21-
COMPONENT_REF_PREFIX,
22-
ModelNameMap,
23-
UnionType,
24-
)
20+
from aws_lambda_powertools.event_handler.openapi.types import COMPONENT_REF_PREFIX, UnionType
2521

2622
from pydantic import TypeAdapter, ValidationError
2723

@@ -34,7 +30,8 @@
3430
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
3531
from pydantic_core import PydanticUndefined, PydanticUndefinedType
3632

37-
from aws_lambda_powertools.event_handler.openapi.types import IncEx
33+
if TYPE_CHECKING:
34+
from aws_lambda_powertools.event_handler.openapi.types import IncExm, ModelNameMap
3835

3936
Undefined = PydanticUndefined
4037
Required = PydanticUndefined

aws_lambda_powertools/event_handler/openapi/types.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
from __future__ import annotations
22

33
import types
4-
from enum import Enum
54
from typing import TYPE_CHECKING, Any, Callable, Dict, Set, Type, TypedDict, Union
65

76
if TYPE_CHECKING:
8-
from pydantic import BaseModel # noqa: F401
7+
from enum import Enum
8+
9+
from pydantic import BaseModel
910
from typing_extensions import NotRequired
1011

11-
CacheKey = Union[Callable[..., Any], None]
12-
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]
13-
TypeModelOrEnum = Union[Type["BaseModel"], Type[Enum]]
14-
ModelNameMap = Dict[TypeModelOrEnum, str]
12+
CacheKey = Union[Callable[..., Any], None]
13+
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]
14+
TypeModelOrEnum = Union[Type[BaseModel], Type[Enum]]
15+
ModelNameMap = Dict[TypeModelOrEnum, str]
16+
1517
UnionType = getattr(types, "UnionType", Union)
1618

1719

0 commit comments

Comments
 (0)