Skip to content

Commit

Permalink
Remove old backwards-compatibility stub (#8596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Aug 3, 2024
1 parent 3b4cf01 commit c13be49
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 169 deletions.
1 change: 1 addition & 0 deletions CHANGES/8596.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed old async compatibility from ``ClientResponse.release()`` -- by :user:`Dreamsorcerer`.
4 changes: 1 addition & 3 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
basicauth_from_netrc,
is_expected_content_type,
netrc_from_env,
noop,
parse_mimetype,
reify,
set_exception,
Expand Down Expand Up @@ -993,15 +992,14 @@ def close(self) -> None:
self._connection.close()
self._connection = None

def release(self) -> Any:
def release(self) -> None:
if not self._released:
self._notify_content()

self._closed = True

self._cleanup_writer()
self._release_connection()
return noop()

@property
def ok(self) -> bool:
Expand Down
6 changes: 0 additions & 6 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Callable,
ContextManager,
Dict,
Generator,
Generic,
Iterable,
Iterator,
Expand Down Expand Up @@ -109,11 +108,6 @@
TOKEN = CHAR ^ CTL ^ SEPARATORS


class noop:
def __await__(self) -> Generator[None, None, None]:
yield


json_re = re.compile(r"(?:application/|[\w.-]+/[\w.+-]+?\+)json$", re.IGNORECASE)


Expand Down
2 changes: 1 addition & 1 deletion aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def release(self) -> None:
All remaining content is read to the void.
"""
await self.resp.release()
self.resp.release()


class BodyPartReader:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ async def handler(request):

jar.update_cookies.reset_mock()
resp = await session.get("/")
await resp.release()
resp.release()

# Filtering the cookie jar before sending the request,
# getting the request URL as only parameter
Expand Down
2 changes: 0 additions & 2 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ async def test_next(self) -> None:

async def test_release(self) -> None:
wrapper = MultipartResponseWrapper(mock.Mock(), mock.Mock())
wrapper.resp.release = make_mocked_coro(None)
await wrapper.release()
assert wrapper.resp.release.called

async def test_release_when_stream_at_eof(self) -> None:
wrapper = MultipartResponseWrapper(mock.Mock(), mock.Mock())
wrapper.resp.release = make_mocked_coro(None)
wrapper.stream.next = make_mocked_coro(b"")
wrapper.stream.at_eof.return_value = True
await wrapper.next()
Expand Down
Loading

0 comments on commit c13be49

Please sign in to comment.