Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
if isinstance(annotation, str):
annotation = ForwardRef(annotation)
annotation = evaluate_forwardref(annotation, globalns, globalns)
+ if annotation is type(None):
+ return None
return annotation
--- /dev/null
+import http
+
+from fastapi import FastAPI
+from fastapi.testclient import TestClient
+
+
+def test_no_content():
+ app = FastAPI()
+
+ @app.get("/no-content", status_code=http.HTTPStatus.NO_CONTENT)
+ def return_no_content() -> "None":
+ return
+
+ client = TestClient(app)
+ response = client.get("/no-content")
+ assert response.status_code == http.HTTPStatus.NO_CONTENT, response.text
+ assert not response.content