From 4baf4b22932774ce50a55e8f64f437ab6320c03e Mon Sep 17 00:00:00 2001 From: Sanghun Lee Date: Thu, 4 Jul 2024 23:48:34 +0900 Subject: [PATCH 1/3] fix: remove outdated codes that use 'AsyncCM' interface --- aiodocker/containers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aiodocker/containers.py b/aiodocker/containers.py index afc7dec8..4b057008 100644 --- a/aiodocker/containers.py +++ b/aiodocker/containers.py @@ -200,7 +200,6 @@ async def _logs_stream(self, cm): try: inspect_info = await self.show() except DockerError: - cm.cancel() raise is_tty = inspect_info["Config"]["Tty"] From f53243957e6561bced5409d793b1d69df24d4981 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Fri, 5 Jul 2024 16:08:41 +0900 Subject: [PATCH 2/3] Add type annotation so that mypy detects the error on "cm.cancel()" --- aiodocker/containers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aiodocker/containers.py b/aiodocker/containers.py index 4b057008..8ae28271 100644 --- a/aiodocker/containers.py +++ b/aiodocker/containers.py @@ -3,6 +3,7 @@ import json import shlex import tarfile +from contextlib import AbstractAsyncContextManager from typing import ( TYPE_CHECKING, Any, @@ -18,7 +19,7 @@ overload, ) -from aiohttp import ClientWebSocketResponse +from aiohttp import ClientResponse, ClientWebSocketResponse from multidict import MultiDict from yarl import URL @@ -196,7 +197,9 @@ def log( else: return self._logs_list(cm) - async def _logs_stream(self, cm): + async def _logs_stream( + self, cm: AbstractAsyncContextManager[ClientResponse] + ) -> AsyncIterator[str]: try: inspect_info = await self.show() except DockerError: @@ -207,7 +210,9 @@ async def _logs_stream(self, cm): async for item in multiplexed_result_stream(response, is_tty=is_tty): yield item - async def _logs_list(self, cm): + async def _logs_list( + self, cm: AbstractAsyncContextManager[ClientResponse] + ) -> Sequence[str]: try: inspect_info = await self.show() except DockerError: @@ -224,6 +229,7 @@ async def get_archive(self, path: str) -> tarfile.TarFile: params={"path": path}, ) as response: data = await parse_result(response) + assert isinstance(data, tarfile.TarFile) return data async def put_archive(self, path, data): From 0179e1dede5fb14a360c014b4aa2b23c7e8adcd8 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Fri, 5 Jul 2024 16:12:59 +0900 Subject: [PATCH 3/3] Add news fragment --- CHANGES/874.fix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/874.fix diff --git a/CHANGES/874.fix b/CHANGES/874.fix new file mode 100644 index 00000000..972044ce --- /dev/null +++ b/CHANGES/874.fix @@ -0,0 +1 @@ +Fix a missing removal of the legacy `AsyncCM` interface usage and update type annotations to avoid this in the future