]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Escalate 0.17 deprecation warnings to becoming fully deprecated. (#1597)
authorTom Christie <tom@tomchristie.com>
Mon, 26 Apr 2021 10:03:11 +0000 (11:03 +0100)
committerGitHub <noreply@github.com>
Mon, 26 Apr 2021 10:03:11 +0000 (11:03 +0100)
httpx/__init__.py
httpx/_client.py
httpx/_status_codes.py
httpx/_utils.py
tests/client/test_client.py
tests/client/test_proxies.py
tests/test_status_codes.py

index 7b130937e5ea028f19dc494bbe96ad47e9f02760..9a27790f4cc4de75eae11df4eaab6056a9234b80 100644 (file)
@@ -35,7 +35,7 @@ from ._exceptions import (
     WriteTimeout,
 )
 from ._models import URL, Cookies, Headers, QueryParams, Request, Response
-from ._status_codes import StatusCode, codes
+from ._status_codes import codes
 from ._transports.asgi import ASGITransport
 from ._transports.base import (
     AsyncBaseTransport,
@@ -100,7 +100,6 @@ __all__ = [
     "RequestNotRead",
     "Response",
     "ResponseNotRead",
-    "StatusCode",
     "stream",
     "StreamClosed",
     "StreamConsumed",
index c5e1f1f223299b9ccfe57d5575e669a98cc53960..371dbe77f47e6680ea749b69a3125ff5348b314c 100644 (file)
@@ -57,7 +57,6 @@ from ._utils import (
     get_environment_proxies,
     get_logger,
     same_origin,
-    warn_deprecated,
 )
 
 # The type annotation for @classmethod and context managers here follows PEP 484
@@ -586,7 +585,6 @@ class Client(BaseClient):
         mounts: typing.Mapping[str, BaseTransport] = None,
         timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
         limits: Limits = DEFAULT_LIMITS,
-        pool_limits: Limits = None,
         max_redirects: int = DEFAULT_MAX_REDIRECTS,
         event_hooks: typing.Mapping[str, typing.List[typing.Callable]] = None,
         base_url: URLTypes = "",
@@ -615,13 +613,6 @@ class Client(BaseClient):
                     "Make sure to install httpx using `pip install httpx[http2]`."
                 ) from None
 
-        if pool_limits is not None:
-            warn_deprecated(
-                "Client(..., pool_limits=...) is deprecated and will raise "
-                "errors in the future. Use Client(..., limits=...) instead."
-            )
-            limits = pool_limits
-
         allow_env_proxies = trust_env and app is None and transport is None
         proxy_map = self._get_proxy_map(proxies, allow_env_proxies)
 
@@ -1280,7 +1271,6 @@ class AsyncClient(BaseClient):
         mounts: typing.Mapping[str, AsyncBaseTransport] = None,
         timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
         limits: Limits = DEFAULT_LIMITS,
-        pool_limits: Limits = None,
         max_redirects: int = DEFAULT_MAX_REDIRECTS,
         event_hooks: typing.Mapping[str, typing.List[typing.Callable]] = None,
         base_url: URLTypes = "",
@@ -1309,13 +1299,6 @@ class AsyncClient(BaseClient):
                     "Make sure to install httpx using `pip install httpx[http2]`."
                 ) from None
 
-        if pool_limits is not None:
-            warn_deprecated(
-                "AsyncClient(..., pool_limits=...) is deprecated and will raise "
-                "errors in the future. Use AsyncClient(..., limits=...) instead."
-            )
-            limits = pool_limits
-
         allow_env_proxies = trust_env and app is None and transport is None
         proxy_map = self._get_proxy_map(proxies, allow_env_proxies)
 
index f7ee6b64a9d8b81456921e571c14df81152cfbe1..100aec641bf9e17942073562258aa33aa0fbf100 100644 (file)
@@ -1,4 +1,3 @@
-import warnings
 from enum import IntEnum
 
 
@@ -142,23 +141,3 @@ class codes(IntEnum):
 # Include lower-case styles for `requests` compatibility.
 for code in codes:
     setattr(codes, code._name_.lower(), int(code))
-
-
-class StatusCodeCompat:
-    def __call__(self, *args, **kwargs):  # type: ignore
-        message = "`httpx.StatusCode` is deprecated. Use `httpx.codes` instead."
-        warnings.warn(message, DeprecationWarning)
-        return codes(*args, **kwargs)
-
-    def __getattr__(self, attr):  # type: ignore
-        message = "`httpx.StatusCode` is deprecated. Use `httpx.codes` instead."
-        warnings.warn(message, DeprecationWarning)
-        return getattr(codes, attr)
-
-    def __getitem__(self, item):  # type: ignore
-        message = "`httpx.StatusCode` is deprecated. Use `httpx.codes` instead."
-        warnings.warn(message, DeprecationWarning)
-        return codes[item]
-
-
-StatusCode = StatusCodeCompat()
index cf136a3ba8e0612c6f180b84bfaf4c87470e7e8b..06995ad508f246aa3dadcf07766382d93cc2e3f7 100644 (file)
@@ -8,7 +8,6 @@ import re
 import sys
 import time
 import typing
-import warnings
 from pathlib import Path
 from urllib.request import getproxies
 
@@ -472,12 +471,11 @@ class URLPattern:
         from ._models import URL
 
         if pattern and ":" not in pattern:
-            warn_deprecated(
+            raise ValueError(
                 f"Proxy keys should use proper URL forms rather "
                 f"than plain scheme strings. "
                 f'Instead of "{pattern}", use "{pattern}://"'
             )
-            pattern += "://"
 
         url = URL(pattern)
         self.pattern = pattern
@@ -535,7 +533,3 @@ class URLPattern:
 
     def __eq__(self, other: typing.Any) -> bool:
         return isinstance(other, URLPattern) and self.pattern == other.pattern
-
-
-def warn_deprecated(message: str) -> None:  # pragma: nocover
-    warnings.warn(message, DeprecationWarning, stacklevel=2)
index c31a1ae6df0ad871dedaac48ac10b172ff1c9a48..01d0de828403d28b5a539443716c8e47609205e0 100644 (file)
@@ -222,16 +222,6 @@ def test_merge_relative_url_with_encoded_slashes():
     assert request.url == "https://www.example.com/base%2Fpath/testing"
 
 
-def test_pool_limits_deprecated():
-    limits = httpx.Limits()
-
-    with pytest.warns(DeprecationWarning):
-        httpx.Client(pool_limits=limits)
-
-    with pytest.warns(DeprecationWarning):
-        httpx.AsyncClient(pool_limits=limits)
-
-
 def test_context_managed_transport():
     class Transport(httpx.BaseTransport):
         def __init__(self):
index b491213daefcdda5902292f94c07e6c236d890d5..d4919031a47f8e717c552ba732ae5f450a40e351 100644 (file)
@@ -256,17 +256,19 @@ def test_proxies_environ(monkeypatch, client_class, url, env, expected):
 
 
 @pytest.mark.parametrize(
-    ["proxies", "expected_scheme"],
+    ["proxies", "is_valid"],
     [
-        ({"http": "http://127.0.0.1"}, "http://"),
-        ({"https": "http://127.0.0.1"}, "https://"),
-        ({"all": "http://127.0.0.1"}, "all://"),
+        ({"http": "http://127.0.0.1"}, False),
+        ({"https": "http://127.0.0.1"}, False),
+        ({"all": "http://127.0.0.1"}, False),
+        ({"http://": "http://127.0.0.1"}, True),
+        ({"https://": "http://127.0.0.1"}, True),
+        ({"all://": "http://127.0.0.1"}, True),
     ],
 )
-def test_for_deprecated_proxy_params(proxies, expected_scheme):
-    with pytest.deprecated_call() as block:
+def test_for_deprecated_proxy_params(proxies, is_valid):
+    if not is_valid:
+        with pytest.raises(ValueError):
+            httpx.Client(proxies=proxies)
+    else:
         httpx.Client(proxies=proxies)
-
-    warning_message = str(block.pop(DeprecationWarning))
-
-    assert expected_scheme in warning_message
index 722e83c527758a2a9d70fbaab53ba58435432440..f253cecd68ceeb876433142b38deb8f132983528 100644 (file)
@@ -1,5 +1,3 @@
-import pytest
-
 import httpx
 
 
@@ -26,14 +24,3 @@ def test_reason_phrase_for_status_code():
 
 def test_reason_phrase_for_unknown_status_code():
     assert httpx.codes.get_reason_phrase(499) == ""
-
-
-def test_deprecated_status_code_class():
-    with pytest.warns(DeprecationWarning):
-        assert httpx.StatusCode.NOT_FOUND == 404
-
-    with pytest.warns(DeprecationWarning):
-        assert httpx.StatusCode(404) == 404
-
-    with pytest.warns(DeprecationWarning):
-        assert httpx.StatusCode["NOT_FOUND"] == 404