From f8074c72d96f73026d6fd730442797f5a5c62207 Mon Sep 17 00:00:00 2001 From: reton2 Date: Wed, 1 May 2024 10:55:30 +0100 Subject: [PATCH] fix: allow callabe in dependant for get_request_handler --- fastapi/routing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index fa1351859..c34a54733 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -208,7 +208,11 @@ def get_request_handler( dependency_overrides_provider: Optional[Any] = None, ) -> Callable[[Request], Coroutine[Any, Any, Response]]: assert dependant.call is not None, "dependant.call must be a function" - is_coroutine = asyncio.iscoroutinefunction(dependant.call) + is_coroutine = ( + asyncio.iscoroutinefunction(dependant.call) + or callable(dependant.call) + and inspect.iscoroutinefunction(dependant.call.__call__) + ) is_body_form = body_field and isinstance(body_field.field_info, params.Form) if isinstance(response_class, DefaultPlaceholder): actual_response_class: Type[Response] = response_class.value