Skip to content

Commit e91cddd

Browse files
Avasamdonbarbos
authored andcommitted
Finish fixing invariance issues
1 parent 699078b commit e91cddd

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

stubs/docker/docker/api/container.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from _typeshed import Incomplete
3-
from typing import Literal, TypedDict, overload, type_check_only
3+
from typing import Any, Literal, TypedDict, overload, type_check_only
44
from typing_extensions import TypeAlias
55

66
from docker._types import WaitContainerResponse
@@ -61,7 +61,9 @@ class ContainerApiMixin:
6161
detach: bool = False,
6262
stdin_open: bool = False,
6363
tty: bool = False,
64-
ports: list[int] | None = None,
64+
# list is invariant, enumerating all possible union combination would be too complex for:
65+
# list[str | int | tuple[int | str, str] | tuple[int | str, ...]]
66+
ports: dict[str, dict[Incomplete, Incomplete]] | list[Any] | None = None,
6567
environment: dict[str, str] | list[str] | None = None,
6668
volumes: str | list[str] | None = None,
6769
network_disabled: bool = False,

stubs/docker/docker/api/network.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23
from typing import Any, Literal, TypedDict, type_check_only
34
from typing_extensions import TypeAlias
45

@@ -43,7 +44,7 @@ class NetworkApiMixin:
4344
ipv4_address: Incomplete | None = None,
4445
ipv6_address: Incomplete | None = None,
4546
aliases: Incomplete | None = None,
46-
links: Incomplete | None = None,
47+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
4748
link_local_ips: Incomplete | None = None,
4849
driver_opt: Incomplete | None = None,
4950
mac_address: Incomplete | None = None,

stubs/docker/docker/models/containers.pyi

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
from _typeshed import Incomplete
3+
from collections.abc import Iterable, Mapping
34
from typing import Literal, NamedTuple, TypedDict, overload
45
from typing_extensions import NotRequired
56

@@ -152,7 +153,7 @@ class ContainerCollection(Collection[Container]):
152153
entrypoint: str | list[str] | None = None,
153154
environment: dict[str, str] | list[str] | None = None,
154155
extra_hosts: dict[str, str] | None = None,
155-
group_add: list[str | int] | None = None,
156+
group_add: Iterable[str | int] | None = None,
156157
healthcheck: dict[Incomplete, Incomplete] | None = None,
157158
hostname: str | None = None,
158159
init: bool | None = None,
@@ -161,7 +162,7 @@ class ContainerCollection(Collection[Container]):
161162
isolation: str | None = None,
162163
kernel_memory: str | int | None = None,
163164
labels: dict[str, str] | list[str] | None = None,
164-
links: dict[str, str | None] | None = None,
165+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
165166
log_config: LogConfig | None = None,
166167
lxc_conf: dict[Incomplete, Incomplete] | None = None,
167168
mac_address: str | None = None,
@@ -181,7 +182,7 @@ class ContainerCollection(Collection[Container]):
181182
pid_mode: str | None = None,
182183
pids_limit: int | None = None,
183184
platform: str | None = None,
184-
ports: dict[str, int | list[int] | tuple[str, int] | None] | None = None,
185+
ports: Mapping[str, int | list[int] | tuple[str, int] | None] | None = None,
185186
privileged: bool = False,
186187
publish_all_ports: bool = False,
187188
read_only: bool | None = None,
@@ -247,7 +248,7 @@ class ContainerCollection(Collection[Container]):
247248
entrypoint: str | list[str] | None = None,
248249
environment: dict[str, str] | list[str] | None = None,
249250
extra_hosts: dict[str, str] | None = None,
250-
group_add: list[str | int] | None = None,
251+
group_add: Iterable[str | int] | None = None,
251252
healthcheck: dict[Incomplete, Incomplete] | None = None,
252253
hostname: str | None = None,
253254
init: bool | None = None,
@@ -256,7 +257,7 @@ class ContainerCollection(Collection[Container]):
256257
isolation: str | None = None,
257258
kernel_memory: str | int | None = None,
258259
labels: dict[str, str] | list[str] | None = None,
259-
links: dict[str, str | None] | None = None,
260+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
260261
log_config: LogConfig | None = None,
261262
lxc_conf: dict[Incomplete, Incomplete] | None = None,
262263
mac_address: str | None = None,
@@ -276,7 +277,7 @@ class ContainerCollection(Collection[Container]):
276277
pid_mode: str | None = None,
277278
pids_limit: int | None = None,
278279
platform: str | None = None,
279-
ports: dict[str, int | list[int] | tuple[str, int] | None] | None = None,
280+
ports: Mapping[str, int | list[int] | tuple[str, int] | None] | None = None,
280281
privileged: bool = False,
281282
publish_all_ports: bool = False,
282283
read_only: bool | None = None,
@@ -338,7 +339,7 @@ class ContainerCollection(Collection[Container]):
338339
entrypoint: str | list[str] | None = None,
339340
environment: dict[str, str] | list[str] | None = None,
340341
extra_hosts: dict[str, str] | None = None,
341-
group_add: list[str | int] | None = None,
342+
group_add: Iterable[str | int] | None = None,
342343
healthcheck: dict[Incomplete, Incomplete] | None = None,
343344
hostname: str | None = None,
344345
init: bool | None = None,
@@ -347,7 +348,7 @@ class ContainerCollection(Collection[Container]):
347348
isolation: str | None = None,
348349
kernel_memory: str | int | None = None,
349350
labels: dict[str, str] | list[str] | None = None,
350-
links: dict[str, str | None] | None = None,
351+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
351352
log_config: LogConfig | None = None,
352353
lxc_conf: dict[Incomplete, Incomplete] | None = None,
353354
mac_address: str | None = None,
@@ -367,7 +368,7 @@ class ContainerCollection(Collection[Container]):
367368
pid_mode: str | None = None,
368369
pids_limit: int | None = None,
369370
platform: str | None = None,
370-
ports: dict[str, int | list[int] | tuple[str, int] | None] | None = None,
371+
ports: Mapping[str, int | list[int] | tuple[str, int] | None] | None = None,
371372
privileged: bool = False,
372373
publish_all_ports: bool = False,
373374
read_only: bool | None = None,

stubs/docker/docker/types/containers.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Iterable, Mapping
3-
from typing import Final, Literal
3+
from typing import Any, Final, Literal
44

55
from docker._types import ContainerWeightDevice
66

@@ -76,7 +76,7 @@ class HostConfig(dict[str, Incomplete]):
7676
port_bindings: Mapping[int | str, Incomplete] | None = None,
7777
lxc_conf: dict[str, Incomplete] | list[dict[str, Incomplete]] | None = None,
7878
publish_all_ports: bool = False,
79-
links: Mapping[str, str | None] | None = None,
79+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
8080
privileged: bool = False,
8181
dns: list[str] | None = None,
8282
dns_search: list[str] | None = None,
@@ -154,7 +154,9 @@ class ContainerConfig(dict[str, Incomplete]):
154154
detach: bool = False,
155155
stdin_open: bool = False,
156156
tty: bool = False,
157-
ports: Mapping[str, int | list[int] | tuple[str, int] | None] | None = None,
157+
# list is invariant, enumerating all possible union combination would be too complex for:
158+
# list[str | int | tuple[int | str, str] | tuple[int | str, ...]]
159+
ports: dict[str, dict[Incomplete, Incomplete]] | list[Any] | None = None,
158160
environment: dict[str, str] | list[str] | None = None,
159161
volumes: str | list[str] | None = None,
160162
network_disabled: bool = False,

stubs/docker/docker/types/networks.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

34
class EndpointConfig(dict[str, Incomplete]):
45
def __init__(
56
self,
67
version: str,
78
aliases: list[Incomplete] | None = None,
8-
links: dict[str, str] | list[str] | None = None,
9+
links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]] | None = None,
910
ipv4_address: str | None = None,
1011
ipv6_address: str | None = None,
1112
link_local_ips: list[str] | None = None,

stubs/docker/docker/utils/utils.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable, Mapping
23
from typing import NamedTuple
34

45
class URLComponents(NamedTuple):
@@ -15,7 +16,7 @@ def decode_json_header(header): ...
1516
def compare_version(v1, v2): ...
1617
def version_lt(v1, v2): ...
1718
def version_gte(v1, v2): ...
18-
def convert_port_bindings(port_bindings): ...
19+
def convert_port_bindings(port_bindings: Mapping[str, int | list[int] | tuple[str, int] | None]): ...
1920
def convert_volume_binds(binds): ...
2021
def convert_tmpfs_mounts(tmpfs): ...
2122
def convert_service_networks(networks): ...
@@ -26,7 +27,7 @@ def kwargs_from_env(environment: Incomplete | None = None): ...
2627
def convert_filters(filters): ...
2728
def datetime_to_timestamp(dt): ...
2829
def parse_bytes(s): ...
29-
def normalize_links(links): ...
30+
def normalize_links(links: dict[str, str] | dict[str, None] | dict[str, str | None] | Iterable[tuple[str, str | None]]): ...
3031
def parse_env_file(env_file): ...
3132
def split_command(command): ...
3233
def format_environment(environment): ...

0 commit comments

Comments
 (0)