diff --git a/fastapi/routing.py b/fastapi/routing.py index 1df3482ce..54d53bbbf 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -3,16 +3,14 @@ import dataclasses import email.message import inspect import json -from contextlib import AsyncExitStack, asynccontextmanager +from contextlib import AsyncExitStack from enum import Enum, IntEnum from typing import ( Any, - AsyncIterator, Callable, Coroutine, Dict, List, - Mapping, Optional, Sequence, Set, @@ -69,7 +67,7 @@ from starlette.routing import ( websocket_session, ) from starlette.routing import Mount as Mount # noqa -from starlette.types import AppType, ASGIApp, Lifespan, Scope +from starlette.types import ASGIApp, Lifespan, Scope from starlette.websockets import WebSocket from typing_extensions import Annotated, Doc, deprecated # type: ignore [attr-defined] @@ -120,6 +118,7 @@ def _prepare_response_content( return dataclasses.asdict(res) return res + async def serialize_response( *, field: Optional[ModelField] = None, diff --git a/tests/test_annotated.py b/tests/test_annotated.py index 26a608822..2222be978 100644 --- a/tests/test_annotated.py +++ b/tests/test_annotated.py @@ -75,6 +75,7 @@ foo_is_short = { ] } + @pytest.mark.parametrize( "path,expected_status,expected_response", [