Skip to content

Commit

Permalink
fix(typing): Don't require annotated_types (#3750)
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut authored Sep 21, 2024
1 parent 06efa69 commit 658350b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions litestar/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
from inspect import Parameter, Signature
from typing import Any, AnyStr, Callable, Collection, ForwardRef, Literal, Mapping, TypeVar, cast

import annotated_types
from litestar.types import Empty

try:
import annotated_types
except ImportError:
annotated_types = Empty # type: ignore[assignment]

from msgspec import UnsetType
from typing_extensions import (
NewType,
Expand All @@ -24,7 +30,6 @@

from litestar.exceptions import ImproperlyConfiguredException, LitestarWarning
from litestar.params import BodyKwarg, DependencyKwarg, KwargDefinition, ParameterKwarg
from litestar.types import Empty
from litestar.types.builtin_types import NoneType, UnionTypes
from litestar.utils.predicates import (
is_any,
Expand All @@ -48,6 +53,9 @@


def _annotated_types_extractor(meta: Any, is_sequence_container: bool) -> dict[str, Any]: # noqa: C901
if annotated_types is Empty: # type: ignore[comparison-overlap] # pragma: no branch
return {} # type: ignore[unreachable] # pragma: no cover

kwargs = {}
if isinstance(meta, annotated_types.GroupedMetadata):
for sub_meta in meta:
Expand Down

0 comments on commit 658350b

Please sign in to comment.