Skip to content

Commit

Permalink
bugfix: Handle return annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrelg committed Dec 12, 2021
1 parent cb334fc commit 6724cbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions starlite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class Config(BaseConfig):
signature = Signature.from_callable(fn)
field_definitions: Dict[str, Tuple[Any, Any]] = {}
for key, value in getfullargspec(fn).annotations.items():

# discard return annotations
if key == "return":
continue

parameter = signature.parameters[key]
if parameter.default is not signature.empty:
field_definitions[key] = (value, parameter.default)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pydantic.fields import ModelField
from starlette.requests import Request

from starlite import HttpMethod, ImproperlyConfiguredException, Provide, get, route, Starlite
from starlite import HttpMethod, ImproperlyConfiguredException, Provide, get, route
from starlite.request import (
create_function_signature_model,
get_kwargs_from_request,
Expand Down Expand Up @@ -97,7 +97,7 @@ async def test_function(data: Person):

@pytest.mark.asyncio
async def test_handle_return_annotation():
@get(path='/health', status_code=204)
@get(path="/health", status_code=204)
async def health_check() -> None:
return

Expand Down

0 comments on commit 6724cbf

Please sign in to comment.