From 0382803c4c228229295ae601dc431e452980fbd2 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 12 May 2024 21:58:56 +0100 Subject: [PATCH] Add many types to docker.api.container (#11911) --- stubs/docker/docker/api/container.pyi | 99 ++++++++++++++------------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/stubs/docker/docker/api/container.pyi b/stubs/docker/docker/api/container.pyi index b220daaaf..b501bfd59 100644 --- a/stubs/docker/docker/api/container.pyi +++ b/stubs/docker/docker/api/container.pyi @@ -5,6 +5,8 @@ from typing_extensions import TypeAlias from docker.types.daemon import CancellableStream +from ..types import ContainerConfig, EndpointConfig, HostConfig, NetworkingConfig + @type_check_only class _HasId(TypedDict): Id: str @@ -43,8 +45,8 @@ class ContainerApiMixin: all: bool = False, trunc: bool = False, latest: bool = False, - since: Incomplete | None = None, - before: Incomplete | None = None, + since: str | None = None, + before: str | None = None, limit: int = -1, size: bool = False, filters: Incomplete | None = None, @@ -52,41 +54,43 @@ class ContainerApiMixin: def create_container( self, image, - command: Incomplete | None = None, - hostname: Incomplete | None = None, - user: Incomplete | None = None, + command: str | list[str] | None = None, + hostname: str | None = None, + user: str | int | None = None, detach: bool = False, stdin_open: bool = False, tty: bool = False, - ports: Incomplete | None = None, - environment: Incomplete | None = None, - volumes: Incomplete | None = None, + ports: list[int] | None = None, + environment: dict[str, str] | list[str] | None = None, + volumes: str | list[str] | None = None, network_disabled: bool = False, - name: Incomplete | None = None, - entrypoint: Incomplete | None = None, - working_dir: Incomplete | None = None, - domainname: Incomplete | None = None, + name: str | None = None, + entrypoint: str | list[str] | None = None, + working_dir: str | None = None, + domainname: str | None = None, host_config: Incomplete | None = None, - mac_address: Incomplete | None = None, - labels: Incomplete | None = None, - stop_signal: Incomplete | None = None, + mac_address: str | None = None, + labels: dict[str, str] | list[str] | None = None, + stop_signal: str | None = None, networking_config: Incomplete | None = None, healthcheck: Incomplete | None = None, - stop_timeout: Incomplete | None = None, - runtime: Incomplete | None = None, + stop_timeout: int | None = None, + runtime: str | None = None, use_config_proxy: bool = True, - platform: Incomplete | None = None, + platform: str | None = None, ): ... - def create_container_config(self, *args, **kwargs): ... + def create_container_config(self, *args, **kwargs) -> ContainerConfig: ... def create_container_from_config(self, config, name: Incomplete | None = None, platform: Incomplete | None = None): ... - def create_host_config(self, *args, **kwargs): ... - def create_networking_config(self, *args, **kwargs): ... - def create_endpoint_config(self, *args, **kwargs): ... - def diff(self, container: _Container): ... - def export(self, container: _Container, chunk_size=2097152): ... - def get_archive(self, container: _Container, path, chunk_size=2097152, encode_stream: bool = False): ... + def create_host_config(self, *args, **kwargs) -> HostConfig: ... + def create_networking_config(self, *args, **kwargs) -> NetworkingConfig: ... + def create_endpoint_config(self, *args, **kwargs) -> EndpointConfig: ... + def diff(self, container: _Container) -> list[dict[Incomplete, Incomplete]]: ... + def export(self, container: _Container, chunk_size: int | None = 2097152): ... + def get_archive( + self, container: _Container, path, chunk_size: int | None = 2097152, encode_stream: bool = False + ) -> tuple[Incomplete, Incomplete]: ... def inspect_container(self, container: _Container): ... - def kill(self, container: _Container, signal: Incomplete | None = None) -> None: ... + def kill(self, container: _Container, signal: str | int | None = None) -> None: ... @overload def logs( self, @@ -128,33 +132,36 @@ class ContainerApiMixin: until: datetime.datetime | float | None = None, ) -> bytes: ... def pause(self, container: _Container) -> None: ... - def port(self, container: _Container, private_port): ... - def put_archive(self, container: _Container, path, data): ... + def port(self, container: _Container, private_port: int): ... + def put_archive(self, container: _Container, path: str, data) -> bool: ... def prune_containers(self, filters: Incomplete | None = None): ... def remove_container(self, container: _Container, v: bool = False, link: bool = False, force: bool = False) -> None: ... - def rename(self, container: _Container, name) -> None: ... - def resize(self, container: _Container, height, width) -> None: ... + def rename(self, container: _Container, name: str) -> None: ... + def resize(self, container: _Container, height: int, width: int) -> None: ... def restart(self, container: _Container, timeout: int = 10) -> None: ... def start(self, container: _Container, *args, **kwargs) -> None: ... - def stats( - self, container: _Container, decode: Incomplete | None = None, stream: bool = True, one_shot: Incomplete | None = None - ): ... - def stop(self, container: _Container, timeout: Incomplete | None = None) -> None: ... - def top(self, container: _Container, ps_args: Incomplete | None = None): ... + def stats(self, container: _Container, decode: bool | None = None, stream: bool = True, one_shot: bool | None = None): ... + def stop(self, container: _Container, timeout: int | None = None) -> None: ... + def top(self, container: _Container, ps_args: str | None = None): ... def unpause(self, container: _Container) -> None: ... def update_container( self, container: _Container, - blkio_weight: Incomplete | None = None, - cpu_period: Incomplete | None = None, - cpu_quota: Incomplete | None = None, - cpu_shares: Incomplete | None = None, - cpuset_cpus: Incomplete | None = None, - cpuset_mems: Incomplete | None = None, - mem_limit: Incomplete | None = None, - mem_reservation: Incomplete | None = None, - memswap_limit: Incomplete | None = None, - kernel_memory: Incomplete | None = None, + blkio_weight: int | None = None, + cpu_period: int | None = None, + cpu_quota: int | None = None, + cpu_shares: int | None = None, + cpuset_cpus: str | None = None, + cpuset_mems: str | None = None, + mem_limit: float | str | None = None, + mem_reservation: float | str | None = None, + memswap_limit: int | str | None = None, + kernel_memory: int | str | None = None, restart_policy: Incomplete | None = None, ): ... - def wait(self, container: _Container, timeout: Incomplete | None = None, condition: Incomplete | None = None): ... + def wait( + self, + container: _Container, + timeout: int | None = None, + condition: Literal["not-running", "next-exit", "removed"] | None = None, + ): ...