Skip to content

Commit

Permalink
Deprecated use of boolean in resp.enable_compression() (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
OisinA authored and asvetlov committed Oct 16, 2018
1 parent 427204b commit e0bd30a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/3318.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecated use of boolean in ``resp.enable_compression()``
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Mun Gwan-gyeong
Nicolas Braem
Nikolay Kim
Nikolay Novik
Oisin Aylward
Olaf Conradi
Pahaz Blinov
Panagiotis Kolokotronis
Expand Down
2 changes: 2 additions & 0 deletions aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
6 changes: 4 additions & 2 deletions tests/test_web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e0bd30a

Please sign in to comment.