Add return type to Docker Container.logs (#11888)

This commit is contained in:
Adam Dangoor
2024-05-12 12:39:18 +01:00
committed by GitHub
parent 488bc24c43
commit 932311d441
2 changed files with 36 additions and 4 deletions

View File

@@ -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(
@@ -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): ...

View File

@@ -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
@@ -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: ...