Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stubs/docker/@tests/test_cases/check_attach.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import annotations

from docker.models.containers import Container


def check_attach_stream(c: Container) -> None:
for line in c.attach(stdout=True, stderr=True, stream=True, logs=True):
line.decode("utf-8")
40 changes: 37 additions & 3 deletions stubs/docker/docker/api/container.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,49 @@ class _TopResult(TypedDict):
_Container: TypeAlias = _HasId | _HasID | str

class ContainerApiMixin:
@overload
def attach(
self,
container: _Container,
stdout: bool = True,
stderr: bool = True,
stream: bool = False,
stream: Literal[False] = False,
logs: bool = False,
demux: bool = False,
): ...
demux: Literal[False] = False,
) -> bytes: ...
@overload
def attach(
self,
container: _Container,
stdout: bool = True,
stderr: bool = True,
stream: Literal[False] = False,
logs: bool = False,
*,
demux: Literal[True],
) -> tuple[bytes | None, bytes | None]: ...
@overload
def attach(
self,
container: _Container,
stdout: bool = True,
stderr: bool = True,
*,
stream: Literal[True],
logs: bool = False,
demux: Literal[False] = False,
) -> CancellableStream[bytes]: ...
@overload
def attach(
self,
container: _Container,
stdout: bool = True,
stderr: bool = True,
*,
stream: Literal[True],
logs: bool = False,
demux: Literal[True],
) -> CancellableStream[tuple[bytes | None, bytes | None]]: ...
def attach_socket(self, container: _Container, params=None, ws: bool = False): ...
def commit(
self,
Expand Down
35 changes: 33 additions & 2 deletions stubs/docker/docker/models/containers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,40 @@ class Container(Model):
def health(self) -> str: ...
@property
def ports(self) -> dict[Incomplete, Incomplete]: ...
@overload
def attach(
self,
*,
stdout: bool = True,
stderr: bool = True,
stream: Literal[False] = False,
logs: bool = False,
demux: Literal[False] = False,
) -> bytes: ...
@overload
def attach(
self,
*,
stdout: bool = True,
stderr: bool = True,
stream: Literal[False] = False,
logs: bool = False,
demux: Literal[True],
) -> tuple[bytes | None, bytes | None]: ...
@overload
def attach(
self,
*,
stdout: bool = True,
stderr: bool = True,
stream: Literal[True],
logs: bool = False,
demux: Literal[False] = False,
) -> CancellableStream[bytes]: ...
@overload
def attach(
self, **kwargs
) -> str | tuple[str | None, str | None] | CancellableStream[str] | CancellableStream[tuple[str | None, str | None]]: ...
self, *, stdout: bool = True, stderr: bool = True, stream: Literal[True], logs: bool = False, demux: Literal[True]
) -> CancellableStream[tuple[bytes | None, bytes | None]]: ...
def attach_socket(self, **kwargs) -> SocketIO | _BufferedReaderStream | SSHSocket: ...
def commit(self, repository: str | None = None, tag: str | None = None, **kwargs) -> Image: ...
def diff(self) -> list[dict[str, Incomplete]]: ...
Expand Down