Skip to content

Commit d9043fc

Browse files
Fixing regression with annotated types
1 parent 873d04d commit d9043fc

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

aws_lambda_powertools/event_handler/openapi/compat.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# We use this for forward reference, as it allows us to handle forward references in type annotations.
1515
from pydantic._internal._typing_extra import eval_type_lenient
1616
from pydantic._internal._utils import lenient_issubclass
17+
from pydantic.fields import FieldInfo as PydanticFieldInfo
1718
from pydantic_core import PydanticUndefined, PydanticUndefinedType
1819
from typing_extensions import Annotated, Literal, get_args, get_origin
1920

@@ -200,15 +201,9 @@ def extract_metadata(ann: Any) -> tuple[Any, list[Any]]:
200201
# If base type is also Annotated, recursively extract its metadata
201202
if get_origin(base_type) is Annotated:
202203
inner_base, inner_metadata = extract_metadata(base_type)
203-
# Combine metadata from both levels, filtering out FieldInfo instances
204-
from pydantic.fields import FieldInfo as PydanticFieldInfo
205-
206204
all_metadata = [m for m in inner_metadata + metadata if not isinstance(m, PydanticFieldInfo)]
207205
return inner_base, all_metadata
208206
else:
209-
# Filter out FieldInfo instances from metadata
210-
from pydantic.fields import FieldInfo as PydanticFieldInfo
211-
212207
constraint_metadata = [m for m in metadata if not isinstance(m, PydanticFieldInfo)]
213208
return base_type, constraint_metadata
214209

aws_lambda_powertools/event_handler/openapi/params.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,6 @@ def get_field_info_annotated_type(annotation, value, is_path_param: bool) -> tup
11311131
# Reconstruct type_annotation with non-FieldInfo metadata if present
11321132
# This ensures constraints like Interval are preserved
11331133
if other_metadata and not has_discriminator_with_param:
1134-
from typing_extensions import Annotated
1135-
11361134
type_annotation = Annotated[(type_annotation, *other_metadata)]
11371135

11381136
# Process the annotation if it exists

0 commit comments

Comments
 (0)