-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[docker] Add missing type annotations in docker.types #15566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| from _typeshed import Incomplete | ||
| from collections.abc import Mapping | ||
| from typing import Any | ||
|
|
||
| class DictType(dict[str, Incomplete]): | ||
| def __init__(self, init: Mapping[str, Incomplete]) -> None: ... | ||
| class DictType(dict[str, Any]): | ||
| def __init__(self, init: Mapping[str, Any]) -> None: ... | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,3 @@ | ||||||||||
| from _typeshed import Incomplete | ||||||||||
| from collections.abc import Iterable, Mapping | ||||||||||
| from typing import Any, Final, Literal | ||||||||||
|
|
||||||||||
|
|
@@ -20,61 +19,61 @@ class LogConfigTypesEnum: | |||||||||
|
|
||||||||||
| class LogConfig(DictType): | ||||||||||
| types: type[LogConfigTypesEnum] | ||||||||||
| def __init__(self, **kwargs) -> None: ... | ||||||||||
| def __init__(self, **kwargs: Any) -> None: ... | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or this
Suggested change
(Depending on whether providing extra, unused keyword arguments is expected or as potential error.) An advanced version would use overloads to prevent |
||||||||||
| @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: ... | ||||||||||
| def __init__(self, **kwargs: Any) -> 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: ... | ||||||||||
| def __init__(self, **kwargs: Any) -> 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, | ||||||||||
| 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 +85,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,15 +112,15 @@ 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, | ||||||||||
| uts_mode: str | None = None, | ||||||||||
| 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 +132,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 +142,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 +155,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, | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,26 @@ | ||
| from typing import Any | ||
|
|
||
| from .base import DictType | ||
|
|
||
| class Healthcheck(DictType): | ||
| def __init__(self, **kwargs) -> None: ... | ||
| def __init__(self, **kwargs: Any) -> 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: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use
Anyas value type. If the dict is generic over the value type, we should use aTypeVarlikedictdoes.