From 96697a835b220daf5053f5520c9ce2588d34d28a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 12 May 2024 16:12:32 +0100 Subject: [PATCH] Add remaining parameter types to docker.api.container logs (#11907) --- stubs/docker/docker/api/container.pyi | 38 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/stubs/docker/docker/api/container.pyi b/stubs/docker/docker/api/container.pyi index 9deb1d16d..3c7bd83fa 100644 --- a/stubs/docker/docker/api/container.pyi +++ b/stubs/docker/docker/api/container.pyi @@ -1,8 +1,20 @@ +import datetime from _typeshed import Incomplete -from typing import Literal, overload +from typing import Literal, TypedDict, overload, type_check_only +from typing_extensions import TypeAlias from docker.types.daemon import CancellableStream +@type_check_only +class _HasId(TypedDict): + Id: str + +@type_check_only +class _HasID(TypedDict): + ID: str + +_Container: TypeAlias = _HasId | _HasID | str + class ContainerApiMixin: def attach( self, container, stdout: bool = True, stderr: bool = True, stream: bool = False, logs: bool = False, demux: bool = False @@ -72,42 +84,42 @@ class ContainerApiMixin: @overload def logs( self, - container, + container: _Container, stdout: bool = True, stderr: bool = True, *, stream: Literal[True], timestamps: bool = False, tail: Literal["all"] | int = "all", - since: Incomplete | None = None, - follow: Incomplete | None = None, - until: Incomplete | None = None, + since: datetime.datetime | float | None = None, + follow: bool | None = None, + until: datetime.datetime | float | None = None, ) -> CancellableStream: ... @overload def logs( self, - container, + container: _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, + since: datetime.datetime | float | None = None, + follow: bool | None = None, + until: datetime.datetime | float | None = None, ) -> CancellableStream: ... @overload def logs( self, - container, + container: _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, + since: datetime.datetime | float | None = None, + follow: bool | None = None, + until: datetime.datetime | float | None = None, ) -> bytes: ... def pause(self, container) -> None: ... def port(self, container, private_port): ...