diff --git a/litestar/typing.py b/litestar/typing.py index ea3db5a62c..4eb3bbe9cc 100644 --- a/litestar/typing.py +++ b/litestar/typing.py @@ -26,7 +26,6 @@ from litestar.types import Empty from litestar.types.builtin_types import NoneType, UnionTypes from litestar.utils.predicates import ( - is_annotated_type, is_any, is_class_and_subclass, is_generic, @@ -150,13 +149,6 @@ def _traverse_metadata( metadata=cast("Sequence[Any]", value), is_sequence_container=is_sequence_container, extra=extra ) ) - elif is_annotated_type(value) and (type_args := [v for v in get_args(value) if v is not None]): - # annotated values can be nested inside other annotated values - # this behaviour is buggy in python 3.8, hence we need to guard here. - if len(type_args) > 1: - constraints.update( - _traverse_metadata(metadata=type_args[1:], is_sequence_container=is_sequence_container, extra=extra) - ) elif unpacked_predicate := _unpack_predicate(value): constraints.update(unpacked_predicate) else: diff --git a/tests/unit/test_openapi/test_schema.py b/tests/unit/test_openapi/test_schema.py index 9544789cc2..21623ec0b2 100644 --- a/tests/unit/test_openapi/test_schema.py +++ b/tests/unit/test_openapi/test_schema.py @@ -306,10 +306,10 @@ class MyDataclass: constrained_int: Annotated[int, annotated_types.Gt(1), annotated_types.Lt(10)] constrained_float: Annotated[float, annotated_types.Ge(1), annotated_types.Le(10)] constrained_date: Annotated[date, annotated_types.Interval(gt=historical_date, lt=today)] - constrained_lower_case: Annotated[str, annotated_types.LowerCase] - constrained_upper_case: Annotated[str, annotated_types.UpperCase] - constrained_is_ascii: Annotated[str, annotated_types.IsAscii] - constrained_is_digit: Annotated[str, annotated_types.IsDigits] + constrained_lower_case: annotated_types.LowerCase[str] + constrained_upper_case: annotated_types.UpperCase[str] + constrained_is_ascii: annotated_types.IsAscii[str] + constrained_is_digit: annotated_types.IsDigit[str] schema = get_schema_for_field_definition(FieldDefinition.from_kwarg(name="MyDataclass", annotation=MyDataclass))