From e17261d6df53243876729ba8cc6330626159481e Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 2 Aug 2026 18:44:17 +0400 Subject: [PATCH 1/2] [docker] Fix context.Context methods --- stubs/docker/docker/context/context.pyi | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/stubs/docker/docker/context/context.pyi b/stubs/docker/docker/context/context.pyi index 1013d0201204..5785ae3cb614 100644 --- a/stubs/docker/docker/context/context.pyi +++ b/stubs/docker/docker/context/context.pyi @@ -1,5 +1,6 @@ -from collections.abc import Mapping -from typing import Any, TypedDict, type_check_only +from typing import TypedDict, type_check_only + +from docker.tls import TLSConfig @type_check_only class _StorageData(TypedDict): @@ -14,9 +15,10 @@ class _Storage(TypedDict): class _Endpoint(TypedDict, total=False): Host: str SkipTLSVerify: bool + DefaultNamespace: str @type_check_only -class _TLSMaterial: +class _TLSMaterial(TypedDict): TLSMaterial: dict[str, list[str]] @type_check_only @@ -27,14 +29,17 @@ class _MetaMetaData(TypedDict, total=False): class _Metadata(TypedDict): Name: str Metadata: _MetaMetaData - Endpoints: Mapping[str, _Endpoint] + Endpoints: dict[str, _Endpoint] + +@type_check_only +class _Context(_Metadata, _TLSMaterial, _Storage): ... class Context: name: str context_type: str | None orchestrator: str | None endpoints: dict[str, _Endpoint] - tls_cfg: dict[str, Any] + tls_cfg: dict[str, TLSConfig] meta_path: str tls_path: str def __init__( @@ -42,23 +47,23 @@ class Context: name: str, orchestrator: str | None = None, host: str | None = None, - endpoints: Mapping[str, _Endpoint] | None = None, + endpoints: dict[str, _Endpoint] | None = None, tls: bool = False, ) -> None: ... def set_endpoint( self, name: str = "docker", host: str | None = None, - tls_cfg: Mapping[str, Any] | None = None, + tls_cfg: TLSConfig | None = None, skip_tls_verify: bool = False, def_namespace: str | None = None, ) -> None: ... - def inspect(self) -> Mapping[str, Any]: ... + def inspect(self) -> _Context: ... @classmethod def load_context(cls, name: str) -> Context | None: ... def save(self) -> None: ... def remove(self) -> None: ... - def __call__(self) -> Mapping[str, Any]: ... + def __call__(self) -> _Context: ... def is_docker_host(self) -> bool: ... @property def Name(self) -> str: ... @@ -69,7 +74,7 @@ class Context: @property def Metadata(self) -> _Metadata: ... @property - def TLSConfig(self) -> Any: ... + def TLSConfig(self) -> TLSConfig: ... @property def TLSMaterial(self) -> _TLSMaterial: ... @property From 0c0ee06eae26c4d56831dd9706c4139bee2c0c85 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 2 Aug 2026 18:49:51 +0400 Subject: [PATCH 2/2] fix name collisions --- stubs/docker/docker/context/context.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/docker/docker/context/context.pyi b/stubs/docker/docker/context/context.pyi index 5785ae3cb614..cffd95233e08 100644 --- a/stubs/docker/docker/context/context.pyi +++ b/stubs/docker/docker/context/context.pyi @@ -1,6 +1,6 @@ from typing import TypedDict, type_check_only -from docker.tls import TLSConfig +from docker.tls import TLSConfig as _TLSConfig @type_check_only class _StorageData(TypedDict): @@ -39,7 +39,7 @@ class Context: context_type: str | None orchestrator: str | None endpoints: dict[str, _Endpoint] - tls_cfg: dict[str, TLSConfig] + tls_cfg: dict[str, _TLSConfig] meta_path: str tls_path: str def __init__( @@ -54,7 +54,7 @@ class Context: self, name: str = "docker", host: str | None = None, - tls_cfg: TLSConfig | None = None, + tls_cfg: _TLSConfig | None = None, skip_tls_verify: bool = False, def_namespace: str | None = None, ) -> None: ... @@ -74,7 +74,7 @@ class Context: @property def Metadata(self) -> _Metadata: ... @property - def TLSConfig(self) -> TLSConfig: ... + def TLSConfig(self) -> _TLSConfig: ... @property def TLSMaterial(self) -> _TLSMaterial: ... @property