Skip to content

Commit 4de1370

Browse files
Use more permissible types in ASGIApp (#3109)
* Use the type.MutableMapping instead of Dict MutableMapping is a slightly more permissible type (allowing the previous Dict type) but matches up to Starlettes tpyes * Update CHANGELOG.md --------- Co-authored-by: Tom Christie <tom@tomchristie.com>
1 parent 87713d2 commit 4de1370

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## Unreleased
88

9+
### Fixed
10+
11+
* Fix `app` type signature in `ASGITransport`. (#3109)
12+
913
## 0.27.0 (21st February, 2024)
1014

1115
### Deprecated

httpx/_transports/asgi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
Event = typing.Union[asyncio.Event, trio.Event]
1717

1818

19-
_Message = typing.Dict[str, typing.Any]
19+
_Message = typing.MutableMapping[str, typing.Any]
2020
_Receive = typing.Callable[[], typing.Awaitable[_Message]]
2121
_Send = typing.Callable[
22-
[typing.Dict[str, typing.Any]], typing.Coroutine[None, None, None]
22+
[typing.MutableMapping[str, typing.Any]], typing.Awaitable[None]
2323
]
2424
_ASGIApp = typing.Callable[
25-
[typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
25+
[typing.MutableMapping[str, typing.Any], _Receive, _Send], typing.Awaitable[None]
2626
]
2727

2828
__all__ = ["ASGITransport"]
@@ -141,7 +141,7 @@ async def receive() -> dict[str, typing.Any]:
141141
return {"type": "http.request", "body": b"", "more_body": False}
142142
return {"type": "http.request", "body": body, "more_body": True}
143143

144-
async def send(message: dict[str, typing.Any]) -> None:
144+
async def send(message: typing.MutableMapping[str, typing.Any]) -> None:
145145
nonlocal status_code, response_headers, response_started
146146

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

0 commit comments

Comments
 (0)