]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Use more permissible types in ASGIApp (#3109)
authorJon Finerty <jon.finerty@isometric.com>
Fri, 23 Feb 2024 13:36:45 +0000 (13:36 +0000)
committerGitHub <noreply@github.com>
Fri, 23 Feb 2024 13:36:45 +0000 (13:36 +0000)
* 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>
CHANGELOG.md
httpx/_transports/asgi.py

index c063c0814a66d108bd9d4d85759c587d102b2752..2d8634f044da2e2dac6686e2254e69f04500b865 100644 (file)
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ## Unreleased
 
+### Fixed
+
+* Fix `app` type signature in `ASGITransport`. (#3109)
+
 ## 0.27.0 (21st February, 2024)
 
 ### Deprecated
index 794cb17bc8c116f6abe76730a2ef3c26e7896e0e..d1828f254d72751eb0447a8b3c6cebe02dc2d293 100644 (file)
@@ -16,13 +16,13 @@ if typing.TYPE_CHECKING:  # pragma: no cover
     Event = typing.Union[asyncio.Event, trio.Event]
 
 
-_Message = typing.Dict[str, typing.Any]
+_Message = typing.MutableMapping[str, typing.Any]
 _Receive = typing.Callable[[], typing.Awaitable[_Message]]
 _Send = typing.Callable[
-    [typing.Dict[str, typing.Any]], typing.Coroutine[None, None, None]
+    [typing.MutableMapping[str, typing.Any]], typing.Awaitable[None]
 ]
 _ASGIApp = typing.Callable[
-    [typing.Dict[str, typing.Any], _Receive, _Send], typing.Coroutine[None, None, None]
+    [typing.MutableMapping[str, typing.Any], _Receive, _Send], typing.Awaitable[None]
 ]
 
 __all__ = ["ASGITransport"]
@@ -141,7 +141,7 @@ class ASGITransport(AsyncBaseTransport):
                 return {"type": "http.request", "body": b"", "more_body": False}
             return {"type": "http.request", "body": body, "more_body": True}
 
-        async def send(message: dict[str, typing.Any]) -> None:
+        async def send(message: typing.MutableMapping[str, typing.Any]) -> None:
             nonlocal status_code, response_headers, response_started
 
             if message["type"] == "http.response.start":