Skip to content

Commit f9aa34f

Browse files
[docker] Add missing type annotations in docker.types
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
1 parent 36811c9 commit f9aa34f

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

stubs/docker/docker/types/base.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from collections.abc import Mapping
2-
from typing import Any
2+
from typing import TypeVar
33

4-
class DictType(dict[str, Any]):
5-
def __init__(self, init: Mapping[str, Any]) -> None: ...
4+
_VT = TypeVar("_VT")
5+
6+
class DictType(dict[str, _VT]):
7+
def __init__(self, init: Mapping[str, _VT]) -> None: ...

stubs/docker/docker/types/containers.pyi

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class LogConfigTypesEnum:
1717
FLUENTD: Final = "fluentd"
1818
NONE: Final = "none"
1919

20-
class LogConfig(DictType):
20+
class LogConfig(DictType[Any]):
2121
types: type[LogConfigTypesEnum]
22-
def __init__(self, **kwargs: Any) -> None: ...
22+
def __init__(
23+
self, *, type: str = ..., Type: str = ..., config: dict[str, str] = ..., Config: dict[str, str] = ...
24+
) -> None: ...
2325
@property
2426
def type(self) -> str: ...
2527
@type.setter
@@ -29,8 +31,10 @@ class LogConfig(DictType):
2931
def set_config_value(self, key: str, value: str) -> None: ...
3032
def unset_config(self, key: str) -> None: ...
3133

32-
class Ulimit(DictType):
33-
def __init__(self, **kwargs: Any) -> None: ...
34+
class Ulimit(DictType[Any]):
35+
def __init__(
36+
self, *, name: str = ..., Name: str = ..., soft: int = ..., Soft: int = ..., hard: int = ..., Hard: int = ...
37+
) -> None: ...
3438
@property
3539
def name(self) -> str: ...
3640
@name.setter
@@ -44,8 +48,21 @@ class Ulimit(DictType):
4448
@hard.setter
4549
def hard(self, value: int | None) -> None: ...
4650

47-
class DeviceRequest(DictType):
48-
def __init__(self, **kwargs: Any) -> None: ...
51+
class DeviceRequest(DictType[Any]):
52+
def __init__(
53+
self,
54+
*,
55+
driver: str = ...,
56+
Driver: str = ...,
57+
count: int = ...,
58+
Count: int = ...,
59+
device_ids: list[str] = ...,
60+
DeviceIDs: list[str] = ...,
61+
capabilities: list[list[str]] = ...,
62+
Capabilities: list[list[str]] = ...,
63+
options: dict[str, str] = ...,
64+
Options: dict[str, str] = ...,
65+
) -> None: ...
4966
@property
5067
def driver(self) -> str: ...
5168
@driver.setter
@@ -72,7 +89,7 @@ class HostConfig(dict[str, Any]):
7289
self,
7390
version: str,
7491
binds: dict[str, Mapping[str, str]] | list[str] | None = None,
75-
port_bindings: Mapping[int | str, Any] | None = None,
92+
port_bindings: Mapping[int | str, Any] | None = None, # Any: int, str, tuple, dict, or list
7693
lxc_conf: dict[str, str] | list[dict[str, str]] | None = None,
7794
publish_all_ports: bool = False,
7895
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,

stubs/docker/docker/types/daemon.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from collections.abc import Iterator
22
from typing import Generic, TypeVar
3+
4+
from requests import Response
35
from typing_extensions import Self
46

57
_T_co = TypeVar("_T_co", covariant=True)
68

79
class CancellableStream(Generic[_T_co]):
8-
def __init__(self, stream: Iterator[_T_co], response) -> None: ...
10+
def __init__(self, stream: Iterator[_T_co], response: Response) -> None: ...
911
def __iter__(self) -> Self: ...
1012
def __next__(self) -> _T_co: ...
1113
next = __next__

stubs/docker/docker/types/healthcheck.pyi

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@ from typing import Any
22

33
from .base import DictType
44

5-
class Healthcheck(DictType):
6-
def __init__(self, **kwargs: Any) -> None: ...
5+
class Healthcheck(DictType[Any]):
6+
def __init__(
7+
self,
8+
*,
9+
test: str | list[str] | None = ...,
10+
Test: str | list[str] | None = ...,
11+
interval: int | None = ...,
12+
Interval: int | None = ...,
13+
timeout: int | None = ...,
14+
Timeout: int | None = ...,
15+
retries: int | None = ...,
16+
Retries: int | None = ...,
17+
start_period: int | None = ...,
18+
StartPeriod: int | None = ...,
19+
) -> None: ...
720
@property
821
def test(self) -> list[str] | None: ...
922
@test.setter

0 commit comments

Comments
 (0)