diff --git a/CHANGES/3318.removal b/CHANGES/3318.removal new file mode 100644 index 00000000000..8c8236e7403 --- /dev/null +++ b/CHANGES/3318.removal @@ -0,0 +1 @@ +Deprecated use of boolean in ``resp.enable_compression()`` diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index cedb4234dd4..fb4639c8461 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -155,6 +155,7 @@ Mun Gwan-gyeong Nicolas Braem Nikolay Kim Nikolay Novik +Oisin Aylward Olaf Conradi Pahaz Blinov Panagiotis Kolokotronis diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py index c6e9afc71d0..f3fc59e43d6 100644 --- a/aiohttp/web_response.py +++ b/aiohttp/web_response.py @@ -131,6 +131,8 @@ def enable_compression(self, force=None): # Backwards compatibility for when force was a bool <0.17. if type(force) == bool: force = ContentCoding.deflate if force else ContentCoding.identity + warnings.warn("Using boolean for force is deprecated #3318", + DeprecationWarning) elif force is not None: assert isinstance(force, ContentCoding), ("force should one of " "None, bool or " diff --git a/tests/test_web_response.py b/tests/test_web_response.py index 5ae43ebb782..8e970fe1a66 100644 --- a/tests/test_web_response.py +++ b/tests/test_web_response.py @@ -326,7 +326,8 @@ async def test_force_compression_no_accept_backwards_compat() -> None: assert not resp.chunked assert not resp.compression - resp.enable_compression(force=True) + with pytest.warns(DeprecationWarning): + resp.enable_compression(force=True) assert resp.compression msg = await resp.prepare(req) @@ -339,7 +340,8 @@ async def test_force_compression_false_backwards_compat() -> None: resp = StreamResponse() assert not resp.compression - resp.enable_compression(force=False) + with pytest.warns(DeprecationWarning): + resp.enable_compression(force=False) assert resp.compression msg = await resp.prepare(req)