Skip to content

Commit

Permalink
Remove outdated codes that use 'AsyncCM' interface (#874)
Browse files Browse the repository at this point in the history
Co-authored-by: Joongi Kim <[email protected]>
  • Loading branch information
fregataa and achimnol authored Jul 5, 2024
1 parent 6e76c68 commit bc500f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/874.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a missing removal of the legacy `AsyncCM` interface usage and update type annotations to avoid this in the future
13 changes: 9 additions & 4 deletions aiodocker/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import shlex
import tarfile
from contextlib import AbstractAsyncContextManager
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -18,7 +19,7 @@
overload,
)

from aiohttp import ClientWebSocketResponse
from aiohttp import ClientResponse, ClientWebSocketResponse
from multidict import MultiDict
from yarl import URL

Expand Down Expand Up @@ -196,19 +197,22 @@ 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"]

async with cm as response:
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:
Expand All @@ -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):
Expand Down

0 comments on commit bc500f4

Please sign in to comment.