mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 12:35:49 +08:00
[docker] Add missing type annotations in docker.types (#15566)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Mapping
|
||||
from typing import TypeVar
|
||||
|
||||
class DictType(dict[str, Incomplete]):
|
||||
def __init__(self, init: Mapping[str, Incomplete]) -> None: ...
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class DictType(dict[str, _VT]):
|
||||
def __init__(self, init: Mapping[str, _VT]) -> None: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable, Mapping
|
||||
from typing import Any, Final, Literal
|
||||
|
||||
@@ -18,63 +17,80 @@ class LogConfigTypesEnum:
|
||||
FLUENTD: Final = "fluentd"
|
||||
NONE: Final = "none"
|
||||
|
||||
class LogConfig(DictType):
|
||||
class LogConfig(DictType[Any]):
|
||||
types: type[LogConfigTypesEnum]
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
def __init__(
|
||||
self, *, type: str = ..., Type: str = ..., config: dict[str, str] = ..., Config: dict[str, str] = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
def type(self): ...
|
||||
def type(self) -> str: ...
|
||||
@type.setter
|
||||
def type(self, value) -> None: ...
|
||||
def type(self, value: str) -> None: ...
|
||||
@property
|
||||
def config(self): ...
|
||||
def set_config_value(self, key, value) -> None: ...
|
||||
def unset_config(self, key) -> None: ...
|
||||
def config(self) -> dict[str, str]: ...
|
||||
def set_config_value(self, key: str, value: str) -> None: ...
|
||||
def unset_config(self, key: str) -> None: ...
|
||||
|
||||
class Ulimit(DictType):
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
class Ulimit(DictType[Any]):
|
||||
def __init__(
|
||||
self, *, name: str = ..., Name: str = ..., soft: int = ..., Soft: int = ..., hard: int = ..., Hard: int = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
def name(self): ...
|
||||
def name(self) -> str: ...
|
||||
@name.setter
|
||||
def name(self, value) -> None: ...
|
||||
def name(self, value: str) -> None: ...
|
||||
@property
|
||||
def soft(self): ...
|
||||
def soft(self) -> int | None: ...
|
||||
@soft.setter
|
||||
def soft(self, value) -> None: ...
|
||||
def soft(self, value: int | None) -> None: ...
|
||||
@property
|
||||
def hard(self): ...
|
||||
def hard(self) -> int | None: ...
|
||||
@hard.setter
|
||||
def hard(self, value) -> None: ...
|
||||
def hard(self, value: int | None) -> None: ...
|
||||
|
||||
class DeviceRequest(DictType):
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
class DeviceRequest(DictType[Any]):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
driver: str = ...,
|
||||
Driver: str = ...,
|
||||
count: int = ...,
|
||||
Count: int = ...,
|
||||
device_ids: list[str] = ...,
|
||||
DeviceIDs: list[str] = ...,
|
||||
capabilities: list[list[str]] = ...,
|
||||
Capabilities: list[list[str]] = ...,
|
||||
options: dict[str, str] = ...,
|
||||
Options: dict[str, str] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def driver(self): ...
|
||||
def driver(self) -> str: ...
|
||||
@driver.setter
|
||||
def driver(self, value) -> None: ...
|
||||
def driver(self, value: str) -> None: ...
|
||||
@property
|
||||
def count(self): ...
|
||||
def count(self) -> int: ...
|
||||
@count.setter
|
||||
def count(self, value) -> None: ...
|
||||
def count(self, value: int) -> None: ...
|
||||
@property
|
||||
def device_ids(self): ...
|
||||
def device_ids(self) -> list[str]: ...
|
||||
@device_ids.setter
|
||||
def device_ids(self, value) -> None: ...
|
||||
def device_ids(self, value: list[str]) -> None: ...
|
||||
@property
|
||||
def capabilities(self): ...
|
||||
def capabilities(self) -> list[list[str]]: ...
|
||||
@capabilities.setter
|
||||
def capabilities(self, value) -> None: ...
|
||||
def capabilities(self, value: list[list[str]]) -> None: ...
|
||||
@property
|
||||
def options(self): ...
|
||||
def options(self) -> dict[str, str]: ...
|
||||
@options.setter
|
||||
def options(self, value) -> None: ...
|
||||
def options(self, value: dict[str, str]) -> None: ...
|
||||
|
||||
class HostConfig(dict[str, Incomplete]):
|
||||
class HostConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
version: str,
|
||||
binds: dict[str, Mapping[str, str]] | list[str] | None = None,
|
||||
port_bindings: Mapping[int | str, Incomplete] | None = None,
|
||||
lxc_conf: dict[str, Incomplete] | list[dict[str, Incomplete]] | None = None,
|
||||
port_bindings: Mapping[int | str, Any] | None = None, # Any: int, str, tuple, dict, or list
|
||||
lxc_conf: dict[str, str] | list[dict[str, str]] | None = None,
|
||||
publish_all_ports: bool = False,
|
||||
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
|
||||
privileged: bool = False,
|
||||
@@ -86,7 +102,7 @@ class HostConfig(dict[str, Incomplete]):
|
||||
cap_add: list[str] | None = None,
|
||||
cap_drop: list[str] | None = None,
|
||||
devices: list[str] | None = None,
|
||||
extra_hosts: dict[str, Incomplete] | list[Incomplete] | None = None,
|
||||
extra_hosts: dict[str, str] | list[str] | None = None,
|
||||
read_only: bool | None = None,
|
||||
pid_mode: str | None = None,
|
||||
ipc_mode: str | None = None,
|
||||
@@ -113,7 +129,7 @@ class HostConfig(dict[str, Incomplete]):
|
||||
sysctls: dict[str, str] | None = None,
|
||||
tmpfs: dict[str, str] | None = None,
|
||||
oom_score_adj: int | None = None,
|
||||
dns_opt: list[Incomplete] | None = None,
|
||||
dns_opt: list[str] | None = None,
|
||||
cpu_shares: int | None = None,
|
||||
cpuset_cpus: str | None = None,
|
||||
userns_mode: str | None = None,
|
||||
@@ -121,7 +137,7 @@ class HostConfig(dict[str, Incomplete]):
|
||||
pids_limit: int | None = None,
|
||||
isolation: str | None = None,
|
||||
auto_remove: bool = False,
|
||||
storage_opt: dict[Incomplete, Incomplete] | None = None,
|
||||
storage_opt: dict[str, str] | None = None,
|
||||
init: bool | None = None,
|
||||
init_path: str | None = None,
|
||||
volume_driver: str | None = None,
|
||||
@@ -133,7 +149,7 @@ class HostConfig(dict[str, Incomplete]):
|
||||
mounts: list[Mount] | None = None,
|
||||
cpu_rt_period: int | None = None,
|
||||
cpu_rt_runtime: int | None = None,
|
||||
device_cgroup_rules: list[Incomplete] | None = None,
|
||||
device_cgroup_rules: list[str] | None = None,
|
||||
device_requests: list[DeviceRequest] | None = None,
|
||||
cgroupns: Literal["private", "host"] | None = None,
|
||||
) -> None: ...
|
||||
@@ -143,7 +159,7 @@ def host_config_version_error(param: str, version: str, less_than: bool = True)
|
||||
def host_config_value_error(param: str, param_value: object) -> ValueError: ...
|
||||
def host_config_incompatible_error(param: str, param_value: str, incompatible_param: str) -> errors.InvalidArgument: ...
|
||||
|
||||
class ContainerConfig(dict[str, Incomplete]):
|
||||
class ContainerConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
version: str,
|
||||
@@ -156,7 +172,7 @@ class ContainerConfig(dict[str, Incomplete]):
|
||||
tty: bool = False,
|
||||
# list is invariant, enumerating all possible union combination would be too complex for:
|
||||
# list[str | int | tuple[int | str, str] | tuple[int | str, ...]]
|
||||
ports: dict[str, dict[Incomplete, Incomplete]] | list[Any] | None = None,
|
||||
ports: dict[str, dict[str, str]] | list[Any] | None = None,
|
||||
environment: dict[str, str] | list[str] | None = None,
|
||||
volumes: str | list[str] | None = None,
|
||||
network_disabled: bool = False,
|
||||
|
||||
@@ -2,10 +2,12 @@ from collections.abc import Iterator
|
||||
from typing import Generic, TypeVar
|
||||
from typing_extensions import Self
|
||||
|
||||
from requests import Response
|
||||
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
|
||||
class CancellableStream(Generic[_T_co]):
|
||||
def __init__(self, stream: Iterator[_T_co], response) -> None: ...
|
||||
def __init__(self, stream: Iterator[_T_co], response: Response) -> None: ...
|
||||
def __iter__(self) -> Self: ...
|
||||
def __next__(self) -> _T_co: ...
|
||||
next = __next__
|
||||
|
||||
@@ -1,24 +1,39 @@
|
||||
from typing import Any
|
||||
|
||||
from .base import DictType
|
||||
|
||||
class Healthcheck(DictType):
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
class Healthcheck(DictType[Any]):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
test: str | list[str] | None = ...,
|
||||
Test: str | list[str] | None = ...,
|
||||
interval: int | None = ...,
|
||||
Interval: int | None = ...,
|
||||
timeout: int | None = ...,
|
||||
Timeout: int | None = ...,
|
||||
retries: int | None = ...,
|
||||
Retries: int | None = ...,
|
||||
start_period: int | None = ...,
|
||||
StartPeriod: int | None = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def test(self): ...
|
||||
def test(self) -> list[str] | None: ...
|
||||
@test.setter
|
||||
def test(self, value) -> None: ...
|
||||
def test(self, value: str | list[str] | None) -> None: ...
|
||||
@property
|
||||
def interval(self): ...
|
||||
def interval(self) -> int | None: ...
|
||||
@interval.setter
|
||||
def interval(self, value) -> None: ...
|
||||
def interval(self, value: int | None) -> None: ...
|
||||
@property
|
||||
def timeout(self): ...
|
||||
def timeout(self) -> int | None: ...
|
||||
@timeout.setter
|
||||
def timeout(self, value) -> None: ...
|
||||
def timeout(self, value: int | None) -> None: ...
|
||||
@property
|
||||
def retries(self): ...
|
||||
def retries(self) -> int | None: ...
|
||||
@retries.setter
|
||||
def retries(self, value) -> None: ...
|
||||
def retries(self, value: int | None) -> None: ...
|
||||
@property
|
||||
def start_period(self): ...
|
||||
def start_period(self) -> int | None: ...
|
||||
@start_period.setter
|
||||
def start_period(self, value) -> None: ...
|
||||
def start_period(self, value: int | None) -> None: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
class EndpointConfig(dict[str, Incomplete]):
|
||||
class EndpointConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
version: str,
|
||||
@@ -10,22 +10,19 @@ class EndpointConfig(dict[str, Incomplete]):
|
||||
ipv4_address: str | None = None,
|
||||
ipv6_address: str | None = None,
|
||||
link_local_ips: list[str] | None = None,
|
||||
driver_opt=None,
|
||||
driver_opt: dict[str, str] | None = None,
|
||||
mac_address: str | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class NetworkingConfig(dict[str, Incomplete]):
|
||||
class NetworkingConfig(dict[str, Any]):
|
||||
def __init__(self, endpoints_config: EndpointConfig | None = None) -> None: ...
|
||||
|
||||
class IPAMConfig(dict[str, Incomplete]):
|
||||
class IPAMConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
driver: str = "default",
|
||||
pool_configs: list[IPAMPool] | None = None,
|
||||
options: dict[Incomplete, Incomplete] | None = None,
|
||||
self, driver: str = "default", pool_configs: list[IPAMPool] | None = None, options: dict[str, str] | None = None
|
||||
) -> None: ...
|
||||
|
||||
class IPAMPool(dict[str, Incomplete]):
|
||||
class IPAMPool(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
subnet: str | None = None,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable, Mapping
|
||||
from typing import Final, Literal, TypedDict, TypeVar, overload, type_check_only
|
||||
from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only
|
||||
|
||||
from .healthcheck import Healthcheck
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class TaskTemplate(dict[str, Incomplete]):
|
||||
class TaskTemplate(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
container_spec: ContainerSpec,
|
||||
@@ -26,14 +25,14 @@ class TaskTemplate(dict[str, Incomplete]):
|
||||
@property
|
||||
def placement(self) -> Placement: ...
|
||||
|
||||
class ContainerSpec(dict[str, Incomplete]):
|
||||
class ContainerSpec(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
image: str,
|
||||
command: str | list[str] | None = None,
|
||||
args: list[str] | None = None,
|
||||
hostname: str | None = None,
|
||||
env: dict[str, Incomplete] | list[str] | None = None,
|
||||
env: dict[str, str | bytes | None] | list[str] | None = None,
|
||||
workdir: str | None = None,
|
||||
user: str | None = None,
|
||||
labels: dict[str, str] | None = None,
|
||||
@@ -57,7 +56,7 @@ class ContainerSpec(dict[str, Incomplete]):
|
||||
sysctls: dict[str, str] | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class Mount(dict[str, Incomplete]):
|
||||
class Mount(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
target: str,
|
||||
@@ -80,7 +79,7 @@ class _ResourceDict(TypedDict):
|
||||
Kind: str
|
||||
Value: int
|
||||
|
||||
class Resources(dict[str, Incomplete]):
|
||||
class Resources(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
cpu_limit: int | None = None,
|
||||
@@ -92,7 +91,7 @@ class Resources(dict[str, Incomplete]):
|
||||
) = None,
|
||||
) -> None: ...
|
||||
|
||||
class UpdateConfig(dict[str, Incomplete]):
|
||||
class UpdateConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
parallelism: int = 0,
|
||||
@@ -110,16 +109,16 @@ class RestartConditionTypesEnum:
|
||||
ON_FAILURE: Final = "on-failure"
|
||||
ANY: Final = "any"
|
||||
|
||||
class RestartPolicy(dict[str, Incomplete]):
|
||||
class RestartPolicy(dict[str, Any]):
|
||||
condition_types: type[RestartConditionTypesEnum]
|
||||
def __init__(
|
||||
self, condition: Literal["none", "on-failure", "any"] = "none", delay: int = 0, max_attempts: int = 0, window: int = 0
|
||||
) -> None: ...
|
||||
|
||||
class DriverConfig(dict[str, Incomplete]):
|
||||
class DriverConfig(dict[str, Any]):
|
||||
def __init__(self, name: str, options: dict[str, str] | None = None) -> None: ...
|
||||
|
||||
class EndpointSpec(dict[str, Incomplete]):
|
||||
class EndpointSpec(dict[str, Any]):
|
||||
def __init__(
|
||||
self, mode: str | None = None, ports: Mapping[str, str | tuple[str | None, ...]] | list[dict[str, str]] | None = None
|
||||
) -> None: ...
|
||||
@@ -129,7 +128,7 @@ def convert_service_ports(ports: list[_T]) -> list[_T]: ...
|
||||
@overload
|
||||
def convert_service_ports(ports: Mapping[str, str | tuple[str | None, ...]]) -> list[dict[str, str]]: ...
|
||||
|
||||
class ServiceMode(dict[str, Incomplete]):
|
||||
class ServiceMode(dict[str, Any]):
|
||||
mode: Literal["replicated", "global", "ReplicatedJob", "GlobalJob"]
|
||||
def __init__(
|
||||
self,
|
||||
@@ -140,7 +139,7 @@ class ServiceMode(dict[str, Incomplete]):
|
||||
@property
|
||||
def replicas(self) -> int | None: ...
|
||||
|
||||
class SecretReference(dict[str, Incomplete]):
|
||||
class SecretReference(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
secret_id: str,
|
||||
@@ -151,7 +150,7 @@ class SecretReference(dict[str, Incomplete]):
|
||||
mode: int = 292,
|
||||
) -> None: ...
|
||||
|
||||
class ConfigReference(dict[str, Incomplete]):
|
||||
class ConfigReference(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
config_id: str,
|
||||
@@ -162,7 +161,7 @@ class ConfigReference(dict[str, Incomplete]):
|
||||
mode: int = 292,
|
||||
) -> None: ...
|
||||
|
||||
class Placement(dict[str, Incomplete]):
|
||||
class Placement(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
constraints: list[str] | None = None,
|
||||
@@ -171,15 +170,15 @@ class Placement(dict[str, Incomplete]):
|
||||
maxreplicas: int | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class PlacementPreference(dict[str, Incomplete]):
|
||||
class PlacementPreference(dict[str, Any]):
|
||||
def __init__(self, strategy: Literal["spread"], descriptor: str) -> None: ...
|
||||
|
||||
class DNSConfig(dict[str, Incomplete]):
|
||||
class DNSConfig(dict[str, Any]):
|
||||
def __init__(
|
||||
self, nameservers: list[str] | None = None, search: list[str] | None = None, options: list[str] | None = None
|
||||
) -> None: ...
|
||||
|
||||
class Privileges(dict[str, Incomplete]):
|
||||
class Privileges(dict[str, Any]):
|
||||
def __init__(
|
||||
self,
|
||||
credentialspec_file: str | None = None,
|
||||
@@ -191,5 +190,5 @@ class Privileges(dict[str, Incomplete]):
|
||||
selinux_level: str | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class NetworkAttachmentConfig(dict[str, Incomplete]):
|
||||
class NetworkAttachmentConfig(dict[str, Any]):
|
||||
def __init__(self, target: str, aliases: list[str] | None = None, options: dict[str, str] | None = None) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user