From fd1e651357cbbd12f01ae4b34519be6211f19493 Mon Sep 17 00:00:00 2001 From: matiuszka Date: Mon, 9 Jan 2023 11:47:46 +0100 Subject: [PATCH] fixup! Fix `NoneType` return type for 204 endpoints --- fastapi/dependencies/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index a4a8c96df1..3d3faec894 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -17,7 +17,6 @@ from typing import ( Union, cast, ) -import types import anyio from fastapi import params @@ -279,7 +278,8 @@ def get_typed_return_annotation(call: Callable[..., Any]) -> Any: globalns = getattr(call, "__globals__", {}) typed_annotation = get_typed_annotation(annotation, globalns) - if typed_annotation is types.NoneType: + NoneType = type(None) + if issubclass(typed_annotation, NoneType): return None return typed_annotation