Skip to content

Commit

Permalink
refactor(typing): move more types into TYPE_CHECKING
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbn committed Aug 28, 2024
1 parent 69cd4d2 commit 4deeecd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 4 additions & 7 deletions aws_lambda_powertools/event_handler/openapi/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@

from dataclasses import dataclass, is_dataclass
from enum import Enum
from typing import Any, Deque, FrozenSet, List, Mapping, Sequence, Set, Tuple, Union
from typing import TYPE_CHECKING, Any, Deque, FrozenSet, List, Mapping, Sequence, Set, Tuple, Union

from typing_extensions import Annotated, Literal, get_origin, get_args

from pydantic import BaseModel, create_model
from pydantic.fields import FieldInfo

from aws_lambda_powertools.event_handler.openapi.types import (
COMPONENT_REF_PREFIX,
ModelNameMap,
UnionType,
)
from aws_lambda_powertools.event_handler.openapi.types import COMPONENT_REF_PREFIX, UnionType

from pydantic import TypeAdapter, ValidationError

Expand All @@ -34,7 +30,8 @@
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
from pydantic_core import PydanticUndefined, PydanticUndefinedType

from aws_lambda_powertools.event_handler.openapi.types import IncEx
if TYPE_CHECKING:
from aws_lambda_powertools.event_handler.openapi.types import IncExm, ModelNameMap

Undefined = PydanticUndefined
Required = PydanticUndefined
Expand Down
14 changes: 8 additions & 6 deletions aws_lambda_powertools/event_handler/openapi/types.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from __future__ import annotations

import types
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, Dict, Set, Type, TypedDict, Union

if TYPE_CHECKING:
from pydantic import BaseModel # noqa: F401
from enum import Enum

from pydantic import BaseModel
from typing_extensions import NotRequired

CacheKey = Union[Callable[..., Any], None]
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]
TypeModelOrEnum = Union[Type["BaseModel"], Type[Enum]]
ModelNameMap = Dict[TypeModelOrEnum, str]
CacheKey = Union[Callable[..., Any], None]
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any]]
TypeModelOrEnum = Union[Type["BaseModel"], Type[Enum]]
ModelNameMap = Dict[TypeModelOrEnum, str]

UnionType = getattr(types, "UnionType", Union)


Expand Down

0 comments on commit 4deeecd

Please sign in to comment.