]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Packaging dependancy tweaks (#1206)
authorJoe <nigelchiang@outlook.com>
Fri, 21 Aug 2020 11:30:57 +0000 (19:30 +0800)
committerGitHub <noreply@github.com>
Fri, 21 Aug 2020 11:30:57 +0000 (12:30 +0100)
* Remove idna and add brotli to extras

* Update dependency docs

* Update BrotliDecoder error message

* Add nocover

Co-authored-by: Tom Christie <tom@tomchristie.com>
README.md
docs/index.md
httpx/_decoders.py
setup.py

index 9697624612b960cb3ae0c1f1ccff6fbad75d7c03..3072daf79ea476fc257a4eab6cc094d828b45d9f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -119,8 +119,8 @@ The HTTPX project relies on these excellent libraries:
   * `h2` - HTTP/2 support. *(Optional)*
 * `certifi` - SSL certificates.
 * `chardet` - Fallback auto-detection for response encoding.
-* `idna` - Internationalized domain name support.
 * `rfc3986` - URL parsing & normalization.
+  * `idna` - Internationalized domain name support.
 * `sniffio` - Async library autodetection.
 * `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*
 * `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*
index 707075324e62327d2083d95330919cb20bc4f711..540c9bdc2d6d7245abd79d81cb2e7ca935def2af 100644 (file)
@@ -108,11 +108,11 @@ The HTTPX project relies on these excellent libraries:
 
 * `httpcore` - The underlying transport implementation for `httpx`.
   * `h11` - HTTP/1.1 support.
-  * `h2` - HTTP/2 support.
+  * `h2` - HTTP/2 support. *(Optional)*
 * `certifi` - SSL certificates.
 * `chardet` - Fallback auto-detection for response encoding.
-* `idna` - Internationalized domain name support.
 * `rfc3986` - URL parsing & normalization.
+  * `idna` - Internationalized domain name support.
 * `sniffio` - Async library autodetection.
 * `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*
 * `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*
@@ -135,6 +135,12 @@ Or, to include the optional HTTP/2 support, use:
 $ pip install httpx[http2]
 ```
 
+To include the optional brotli decoder support, use:
+
+```shell
+$ pip install httpx[brotli]
+```
+
 HTTPX requires Python 3.6+
 
 [sync-support]: https://github.com/encode/httpx/issues/572
index c3959f846770a00b3b8f9cbd335482543ab9265f..fa9f8124a234f48def72691ca0b072a72c7cc28f 100644 (file)
@@ -108,9 +108,13 @@ class BrotliDecoder(Decoder):
     """
 
     def __init__(self, request: "Request") -> None:
-        assert (
-            brotli is not None
-        ), "The 'brotlipy' or 'brotli' library must be installed to use 'BrotliDecoder'"
+        if brotli is None:  # pragma: nocover
+            raise ImportError(
+                "Using 'BrotliDecoder', but the 'brotlipy' or 'brotli' library "
+                "is not installed."
+                "Make sure to install httpx using `pip install httpx[brotli]`."
+            ) from None
+
         self.request = request
         self.decompressor = brotli.Decompressor()
         self.seen_data = False
index 1b449a40c9f07a96d873c0cd56b731a005b5e384..e811d2a8e723e919c0398a40db712e61d4454959 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -58,12 +58,12 @@ setup(
         "certifi",
         "sniffio",
         "chardet==3.*",
-        "idna==2.*",
-        "rfc3986>=1.3,<2",
+        "rfc3986[idna2008]>=1.3,<2",
         "httpcore==0.10.*",
     ],
     extras_require={
         "http2": "h2==3.*",
+        "brotli": "brotlipy==0.7.*",
     },
     classifiers=[
         "Development Status :: 4 - Beta",