Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastapi_decorators/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def decorator(func: F) -> F:

new_signature = original_signature.replace(
parameters=tuple(all_params.values()),
return_annotation=hints.get("return", original_signature.return_annotation),
return_annotation=original_signature.return_annotation,
)

wrapper = _create_wrapper(func, all_params)
Expand Down
21 changes: 21 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from time import sleep, time
from fastapi import FastAPI, status
from fastapi.testclient import TestClient
import pytest
from tests.app import app, fake_db, rate_limit_store, cache_storage, error_log
from fastapi_decorators import depends

client = TestClient(app)

Expand Down Expand Up @@ -168,3 +170,22 @@ def test_expects_header() -> None:
response = client.get("/headers", headers=headers)
assert response.status_code == 200
assert response.json() == headers


def test_depends_keeps_none_return_annotation_for_204() -> None:
test_app = FastAPI()

@depends
def with_test() -> None:
pass

@test_app.get("/test", status_code=status.HTTP_204_NO_CONTENT)
@with_test
async def endpoint() -> None:
pass

assert endpoint is not None
test_client = TestClient(test_app)
response = test_client.get("/test")
assert response.status_code == status.HTTP_204_NO_CONTENT
assert response.content == b""
Loading