Skip to content
Merged
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
4 changes: 4 additions & 0 deletions stubs/docker/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ docker.models.resource.Collection.model
# keyword arguments are now unsupported
docker.api.container.ContainerApiMixin.start

# implementation has *args and **kwargs params that can't be used
docker.client.DockerClient.info
docker.client.DockerClient.ping

# Internal-use module for types shared by multiple modules.
docker._types
2 changes: 1 addition & 1 deletion stubs/docker/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = "7.1.*"
version = "7.2.*"
upstream-repository = "https://github.com/docker/docker-py"
dependencies = ["types-paramiko", "types-requests", "urllib3>=2"]
2 changes: 1 addition & 1 deletion stubs/docker/docker/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Final

from .api import APIClient as APIClient
from .client import DockerClient as DockerClient, from_env as from_env
from .client import DockerClient as DockerClient, from_context as from_context, from_env as from_env
from .context import Context as Context, ContextAPI as ContextAPI
from .tls import TLSConfig as TLSConfig
from .version import __version__ as __version__
Expand Down
55 changes: 47 additions & 8 deletions stubs/docker/docker/client.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Iterable
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
from typing import Any, Literal, NoReturn, Protocol, overload, type_check_only

from docker import APIClient
Expand All @@ -12,6 +13,7 @@ from docker.models.secrets import SecretCollection
from docker.models.services import ServiceCollection
from docker.models.swarm import Swarm
from docker.models.volumes import VolumeCollection
from docker.tls import TLSConfig
from docker.types import CancellableStream

@type_check_only
Expand All @@ -21,17 +23,45 @@ class _Environ(Protocol):

class DockerClient:
api: APIClient
def __init__(self, *args, **kwargs) -> None: ...
# Please keep in sync with docker.APIClient
def __init__(
self,
base_url: str | None = None,
version: str | None = None,
timeout: int = 60,
tls: bool | TLSConfig = False,
user_agent: str = ...,
num_pools: int | None = None,
credstore_env: Mapping[Incomplete, Incomplete] | None = None,
use_ssh_client: bool = False,
max_pool_size: int = 10,
) -> None: ...
@classmethod
def from_env(
cls,
*,
version: str | None = None,
timeout: int = ...,
max_pool_size: int = ...,
timeout: int = 60,
max_pool_size: int = 10,
environment: _Environ | None = None,
use_ssh_client: bool = False,
use_context: bool = True,
) -> DockerClient: ...
@classmethod
def from_context(
cls,
name=None,
*,
version: str | None = None,
timeout: int = 60,
max_pool_size: int = 10,
use_ssh_client: bool = False,
base_url: str | None = None,
tls: bool | TLSConfig = False,
user_agent: str = ...,
num_pools: int | None = None,
credstore_env: Mapping[Incomplete, Incomplete] | None = None,
): ...
@property
def configs(self) -> ConfigCollection: ...
@property
Expand Down Expand Up @@ -59,11 +89,20 @@ class DockerClient:
def events(self, *args, decode: Literal[True] = ..., **kwargs) -> CancellableStream[dict[str, Any]]: ...

def df(self) -> dict[str, Any]: ...
def info(self, *args, **kwargs) -> dict[str, Any]: ...
def login(self, *args, **kwargs) -> dict[str, Any]: ...
def ping(self, *args, **kwargs) -> bool: ...
def version(self, *args, **kwargs) -> dict[str, Any]: ...
def info(self) -> dict[str, Any]: ...
def login(
self,
username: str,
password: str | None = None,
email: str | None = None,
registry: str | None = None,
reauth: bool = False,
dockercfg_path: str | None = None,
) -> dict[str, Any]: ...
def ping(self) -> bool: ...
def version(self, api_version: bool = True) -> dict[str, Any]: ...
def close(self) -> None: ...
def __getattr__(self, name: str) -> NoReturn: ...

from_env = DockerClient.from_env
from_context = DockerClient.from_context
7 changes: 6 additions & 1 deletion stubs/docker/docker/context/api.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Sequence
from _typeshed import Incomplete
from collections.abc import Mapping, Sequence

from docker.context.context import Context
from docker.tls import TLSConfig
Expand All @@ -22,6 +23,10 @@ class ContextAPI:
@classmethod
def get_current_context(cls) -> Context: ...
@classmethod
def kwargs_from_context(
cls, name: str | None = None, environment: Mapping[str, str | None] | None = None
) -> dict[str, Incomplete]: ... # TODO: Use TypedDict
Comment thread
donbarbos marked this conversation as resolved.
Outdated
@classmethod
def set_current_context(cls, name: str = "default") -> None: ...
@classmethod
def remove_context(cls, name: str) -> None: ...
Expand Down
1 change: 1 addition & 0 deletions stubs/docker/docker/types/services.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Mount(dict[str, Any]):
driver_config: DriverConfig | None = None,
tmpfs_size: int | str | None = None,
tmpfs_mode: int | None = None,
subpath: str | None = None,
) -> None: ...
@classmethod
def parse_mount_string(cls, string: str) -> Mount: ...
Expand Down