Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add return type to Docker Container.logs #11888

Merged
merged 5 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 33 additions & 3 deletions stubs/docker/docker/api/container.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from _typeshed import Incomplete
from typing import Literal
from typing import Literal, overload

from docker.types.daemon import CancellableStream

class ContainerApiMixin:
def attach(
Expand Down Expand Up @@ -67,18 +69,46 @@ class ContainerApiMixin:
def get_archive(self, container, path, chunk_size=2097152, encode_stream: bool = False): ...
def inspect_container(self, container): ...
def kill(self, container, signal: Incomplete | None = None) -> None: ...
@overload
def logs(
self,
container,
stdout: bool = True,
stderr: bool = True,
stream: bool = False,
*,
stream: Literal[True],
timestamps: bool = False,
tail: Literal["all"] | int = "all",
since: Incomplete | None = None,
follow: Incomplete | None = None,
until: Incomplete | None = None,
): ...
) -> CancellableStream: ...
@overload
def logs(
self,
container,
stdout: bool,
stderr: bool,
stream: Literal[True],
timestamps: bool = False,
tail: Literal["all"] | int = "all",
since: Incomplete | None = None,
follow: Incomplete | None = None,
until: Incomplete | None = None,
) -> CancellableStream: ...
@overload
def logs(
self,
container,
stdout: bool = True,
stderr: bool = True,
stream: Literal[False] = False,
timestamps: bool = False,
tail: Literal["all"] | int = "all",
since: Incomplete | None = None,
follow: Incomplete | None = None,
until: Incomplete | None = None,
) -> bytes: ...
def pause(self, container) -> None: ...
def port(self, container, private_port): ...
def put_archive(self, container, path, data): ...
Expand Down
4 changes: 3 additions & 1 deletion stubs/docker/docker/models/containers.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _typeshed import Incomplete
from typing import NamedTuple

from docker.types.daemon import CancellableStream

from .images import Image
from .resource import Collection, Model

Expand Down Expand Up @@ -40,7 +42,7 @@ class Container(Model):
def export(self, chunk_size=2097152): ...
def get_archive(self, path, chunk_size=2097152, encode_stream: bool = False): ...
def kill(self, signal: Incomplete | None = None): ...
def logs(self, **kwargs): ...
def logs(self, **kwargs) -> CancellableStream | bytes: ...
def pause(self): ...
def put_archive(self, path, data): ...
def remove(self, **kwargs) -> None: ...
Expand Down