diff --git a/fastapi/routing.py b/fastapi/routing.py index ab0ea0b515..2f0dcc5268 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -100,8 +100,11 @@ def request_response( and returns an ASGI application. """ f: Callable[[Request], Awaitable[Response]] = ( - func if is_async_callable(func) else functools.partial(run_in_threadpool, func) # type:ignore # ty: ignore[unused-ignore-comment] - ) # ty: ignore + f: Callable[[Request], Awaitable[Response]] = ( + func # type: ignore[assignment] # ty: ignore[unused-ignore-comment] + if is_async_callable(func) + else functools.partial(run_in_threadpool, func) # type: ignore[call-arg] # ty: ignore[unused-ignore-comment] + ) # ty: ignore[invalid-assignment] async def app(scope: Scope, receive: Receive, send: Send) -> None: request = Request(scope, receive, send)