Add types for container and net_id parameters in docker/api/network (#12042)

This commit is contained in:
Adam Dangoor
2024-06-24 10:31:02 +01:00
committed by GitHub
parent c8898742e0
commit f66d687b08

View File

@@ -1,8 +1,20 @@
from _typeshed import Incomplete
from typing import Any, Literal
from typing import Any, Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
from docker.types import IPAMConfig
@type_check_only
class _HasId(TypedDict):
Id: str
@type_check_only
class _HasID(TypedDict):
ID: str
_Network: TypeAlias = _HasId | _HasID | str
_Container: TypeAlias = _HasId | _HasID | str
class NetworkApiMixin:
def networks(self, names: Incomplete | None = None, ids: Incomplete | None = None, filters: Incomplete | None = None): ...
def create_network(
@@ -20,12 +32,12 @@ class NetworkApiMixin:
ingress: bool | None = None,
) -> dict[str, str]: ...
def prune_networks(self, filters: Incomplete | None = None): ...
def remove_network(self, net_id) -> None: ...
def inspect_network(self, net_id, verbose: Incomplete | None = None, scope: Incomplete | None = None): ...
def remove_network(self, net_id: _Network) -> None: ...
def inspect_network(self, net_id: _Network, verbose: Incomplete | None = None, scope: Incomplete | None = None): ...
def connect_container_to_network(
self,
container,
net_id,
container: _Container,
net_id: str,
ipv4_address: Incomplete | None = None,
ipv6_address: Incomplete | None = None,
aliases: Incomplete | None = None,
@@ -34,4 +46,4 @@ class NetworkApiMixin:
driver_opt: Incomplete | None = None,
mac_address: Incomplete | None = None,
) -> None: ...
def disconnect_container_from_network(self, container, net_id, force: bool = False) -> None: ...
def disconnect_container_from_network(self, container: _Container, net_id: str, force: bool = False) -> None: ...