From 151bf3e3dc70bd7afe223976c495f5c3dfd6bcda Mon Sep 17 00:00:00 2001 From: matiuszka Date: Mon, 9 Jan 2023 11:39:07 +0100 Subject: [PATCH] Fix `NoneType` return type for 204 endpoints --- fastapi/dependencies/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 32e171f188..f68fcf7496 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -276,7 +276,12 @@ def get_typed_return_annotation(call: Callable[..., Any]) -> Any: return None globalns = getattr(call, "__globals__", {}) - return get_typed_annotation(annotation, globalns) + typed_annotation = get_typed_annotation(annotation, globalns) + + if typed_annotation is type(None): + return None + + return typed_annotation def get_dependant(