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 diff --git a/aiodocker/containers.py b/aiodocker/containers.py index afc7dec8..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,11 +197,12 @@ 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: - cm.cancel() raise is_tty = inspect_info["Config"]["Tty"] @@ -208,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: @@ -225,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):