]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Merge branch 'master' into async-dependencies-optional
authorTom Christie <tom@tomchristie.com>
Fri, 27 Sep 2024 12:00:30 +0000 (13:00 +0100)
committerGitHub <noreply@github.com>
Fri, 27 Sep 2024 12:00:30 +0000 (13:00 +0100)
1  2 
README.md
docs/async.md
httpx/_transports/asgi.py
httpx/_transports/default.py
httpx/_utils.py
pyproject.toml
requirements.txt

diff --cc README.md
index f3238242ecdf2f3f42249a98afc455cf2f406775,d5d21487133816b7c4bdf45b2ee8b98b96895690..15d52d45f36061e27b3b8bd051cedcf54e280836
+++ b/README.md
@@@ -134,13 -132,13 +134,14 @@@ The HTTPX project relies on these excel
  
  As well as these optional installs:
  
 -* `h2` - HTTP/2 support. *(Optional, with `httpx[http2]`)*
 -* `socksio` - SOCKS proxy support. *(Optional, with `httpx[socks]`)*
 -* `rich` - Rich terminal support. *(Optional, with `httpx[cli]`)*
 -* `click` - Command line client support. *(Optional, with `httpx[cli]`)*
 -* `brotli` or `brotlicffi` - Decoding for "brotli" compressed responses. *(Optional, with `httpx[brotli]`)*
 +* `anyio` - Async support for `asyncio`. *(Optional, with `httpx['asyncio']`)*
 +* `trio` - Async support for `trio`. *(Optional, with `httpx['trio']`)*
 +* `h2` - HTTP/2 support. *(Optional, with `httpx['http2']`)*
 +* `socksio` - SOCKS proxy support. *(Optional, with `httpx['socks']`)*
 +* `rich` - Rich terminal support. *(Optional, with `httpx['cli']`)*
 +* `click` - Command line client support. *(Optional, with `httpx['cli']`)*
 +* `brotli` or `brotlicffi` - Decoding for "brotli" compressed responses. *(Optional, with `httpx['brotli']`)*
+ * `zstandard` - Decoding for "zstd" compressed responses. *(Optional, with `httpx[zstd]`)*
  
  A huge amount of credit is due to `requests` for the API layout that
  much of this work follows, as well as to `urllib3` for plenty of design
diff --cc docs/async.md
Simple merge
index fd9ffdce811a6d05f2bfcae7882fe3b520095dfe,8578d4aeff207f2b159ed6fb9fd43385e27ced69..17ad2b0a14cd524daa90ad30e5187c1c446b3752
@@@ -1,5 -1,9 +1,7 @@@
+ from __future__ import annotations
  import typing
  
 -import sniffio
 -
  from .._models import Request, Response
  from .._types import AsyncByteStream
  from .base import AsyncBaseTransport
@@@ -12,19 -16,19 +14,21 @@@ if typing.TYPE_CHECKING:  # pragma: no 
      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"]
  
 -def create_event() -> Event:
 +def create_event() -> "Event":
 +    import sniffio
 +
      if sniffio.current_async_library() == "trio":
          import trio
  
index 9e9ce90e0274d107fcd43c025779183dfcba898c,33db416dd19f4247c4814a18e79378eafd2337e0..3ebf210249e22d0396caf259c975050b04121600
@@@ -266,20 -271,12 +271,20 @@@ class AsyncHTTPTransport(AsyncBaseTrans
          http2: bool = False,
          limits: Limits = DEFAULT_LIMITS,
          trust_env: bool = True,
-         proxy: typing.Optional[ProxyTypes] = None,
-         uds: typing.Optional[str] = None,
-         local_address: typing.Optional[str] = None,
+         proxy: ProxyTypes | None = None,
+         uds: str | None = None,
+         local_address: str | None = None,
          retries: int = 0,
-         socket_options: typing.Optional[typing.Iterable[SOCKET_OPTION]] = None,
+         socket_options: typing.Iterable[SOCKET_OPTION] | None = None,
      ) -> None:
 +        try:
 +            import sniffio  # noqa: F401
 +        except ImportError:  # pragma: nocover
 +            raise RuntimeError(
 +                "Using httpx in async mode, but neither "
 +                "httpx['asyncio'] or asyncio['trio'] is installed."
 +            )
 +
          ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
          proxy = Proxy(url=proxy) if isinstance(proxy, (str, URL)) else proxy
  
diff --cc httpx/_utils.py
Simple merge
diff --cc pyproject.toml
index 271694d22eeb37d3468f9067ab028ce7a5fdefbf,c4c188052e61c216972258bbe51126c97348785d..484989a1d86ad2c6acb6a4c2624b6bb360fa288e
@@@ -45,17 -47,14 +45,20 @@@ cli = 
      "rich>=10,<14",
  ]
  http2 = [
 -    "h2>=3,<5",
 +    "httpcore[http2]",
  ]
  socks = [
 -    "socksio==1.*",
 +    "httpcore[socks]",
 +]
 +asyncio = [
 +    "httpcore[asyncio]"
 +]
 +trio = [
 +    "httpcore[trio]"
  ]
+ zstd = [
+   "zstandard>=0.18.0",
+ ]
  
  [project.scripts]
  httpx = "httpx:main"
index 31f05044054fbd8c27720d7b2202d12dd0d2a3f8,5aab03767cdc1fc9b2a165477cd2da45e68919de..bb2ddd202ce5505301b74c4f3a64b6fc0966d79d
@@@ -2,27 -2,28 +2,27 @@@
  # On the other hand, we're not pinning package dependencies, because our tests
  # needs to pass with the latest version of the packages.
  # Reference: https://github.com/encode/httpx/pull/1721#discussion_r661241588
- -e .[asyncio,trio,brotli,cli,http2,socks]
 --e .[brotli,cli,http2,socks,zstd]
++-e .[asyncio,trio,brotli,cli,http2,socks,zstd]
  
  # Optional charset auto-detection
  # Used in our test cases
  chardet==5.2.0
  
  # Documentation
- mkdocs==1.5.3
+ mkdocs==1.6.1
  mkautodoc==0.2.0
- mkdocs-material==9.5.3
+ mkdocs-material==9.5.34
  
  # Packaging
- build==1.0.3
- twine==4.0.2
+ build==1.2.1
+ twine==5.1.1
  
  # Tests & Linting
- coverage[toml]==7.4.0
- cryptography==41.0.7
- mypy==1.8.0
- pytest==7.4.4
- ruff==0.1.9
- trio==0.22.2
+ coverage[toml]==7.6.1
+ cryptography==43.0.1
+ mypy==1.11.2
+ pytest==8.3.2
+ ruff==0.6.3
+ trio==0.26.2
 -trio-typing==0.10.0
  trustme==1.1.0
- uvicorn==0.24.0.post1
+ uvicorn==0.30.6