Skip to content

Commit

Permalink
Review type declarations and usage in asgi.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jhominal committed Jan 15, 2024
1 parent 15f9253 commit cf989ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions httpx/_transports/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

_Message = typing.Dict[str, typing.Any]
_Receive = typing.Callable[[], typing.Awaitable[_Message]]
_Send = typing.Callable[
[typing.Dict[str, typing.Any]], typing.Coroutine[None, None, None]
]
_Send = typing.Callable[[_Message], typing.Awaitable[None]]
_ASGIApp = typing.Callable[
[typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
[typing.Dict[str, typing.Any], _Receive, _Send], typing.Awaitable[None]
]


Expand Down Expand Up @@ -123,7 +121,7 @@ async def handle_async_request(

# ASGI callables.

async def receive() -> typing.Dict[str, typing.Any]:
async def receive() -> _Message:
nonlocal request_complete

if request_complete:
Expand All @@ -137,7 +135,7 @@ async def receive() -> typing.Dict[str, typing.Any]:
return {"type": "http.request", "body": b"", "more_body": False}
return {"type": "http.request", "body": body, "more_body": True}

async def send(message: typing.Dict[str, typing.Any]) -> None:
async def send(message: _Message) -> None:
nonlocal status_code, response_headers, response_started

if message["type"] == "http.response.start":
Expand Down

0 comments on commit cf989ae

Please sign in to comment.