Skip to content

refactor(typing): move more types into TYPE_CHECKING #5088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 IncEx, 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
Loading