diff --git a/podman/api/http_utils.py b/podman/api/http_utils.py index d68179d1..e0bb062e 100644 --- a/podman/api/http_utils.py +++ b/podman/api/http_utils.py @@ -100,5 +100,5 @@ def _filter_values(mapping: Mapping[str, Any], recursion=False) -> dict[str, Any return canonical -def encode_auth_header(auth_config: Dict[str, str]) -> str: +def encode_auth_header(auth_config: dict[str, str]) -> str: return base64.urlsafe_b64encode(json.dumps(auth_config).encode('utf-8')) diff --git a/podman/domain/images_manager.py b/podman/domain/images_manager.py index 0269e988..fedad93b 100644 --- a/podman/domain/images_manager.py +++ b/podman/domain/images_manager.py @@ -32,6 +32,8 @@ logger = logging.getLogger("podman.images") +builtin_list = list + class ImagesManager(BuildMixin, Manager): """Specialized Manager for Image resources.""" @@ -300,7 +302,7 @@ def push( @staticmethod def _push_helper( - decode: bool, body: list[dict[str, Any]] + decode: bool, body: builtin_list[dict[str, Any]] ) -> Iterator[Union[str, dict[str, Any]]]: """Helper needed to allow push() to return either a generator or a str.""" for entry in body: @@ -316,7 +318,7 @@ def pull( tag: Optional[str] = None, all_tags: bool = False, **kwargs, - ) -> Union[Image, list[Image], Iterator[str]]: + ) -> Union[Image, builtin_list[Image], Iterator[str]]: """Request Podman service to pull image(s) from repository. Args: @@ -459,7 +461,7 @@ def remove( image: Union[Image, str], force: Optional[bool] = None, noprune: bool = False, # pylint: disable=unused-argument - ) -> list[dict[Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]: + ) -> builtin_list[dict[Literal["Deleted", "Untagged", "Errors", "ExitCode"], Union[str, int]]]: """Delete image from Podman service. Args: @@ -486,7 +488,7 @@ def remove( results.append({"ExitCode": body["ExitCode"]}) return results - def search(self, term: str, **kwargs) -> list[dict[str, Any]]: + def search(self, term: str, **kwargs) -> builtin_list[dict[str, Any]]: """Search Images on registries. Args: diff --git a/podman/domain/networks.py b/podman/domain/networks.py index b509132a..bbc89539 100644 --- a/podman/domain/networks.py +++ b/podman/domain/networks.py @@ -24,7 +24,7 @@ class Network(PodmanResource): """Details and configuration for a networks managed by the Podman service. Attributes: - attrs (Dict[str, Any]): Attributes of Network reported from Podman service + attrs (dict[str, Any]): Attributes of Network reported from Podman service """ @property @@ -41,7 +41,7 @@ def id(self): # pylint: disable=invalid-name @property def containers(self): - """List[Container]: Returns list of Containers connected to network.""" + """list[Container]: Returns list of Containers connected to network.""" with suppress(KeyError): container_manager = ContainersManager(client=self.client) return [container_manager.get(ident) for ident in self.attrs["Containers"].keys()] @@ -71,12 +71,12 @@ def connect(self, container: Union[str, Container], *_, **kwargs) -> None: container: To add to this Network Keyword Args: - aliases (List[str]): Aliases to add for this endpoint - driver_opt (Dict[str, Any]): Options to provide to network driver + aliases (list[str]): Aliases to add for this endpoint + driver_opt (dict[str, Any]): Options to provide to network driver ipv4_address (str): IPv4 address for given Container on this network ipv6_address (str): IPv6 address for given Container on this network - link_local_ips (List[str]): list of link-local addresses - links (List[Union[str, Containers]]): Ignored + link_local_ips (list[str]): list of link-local addresses + links (list[Union[str, Containers]]): Ignored Raises: APIError: when Podman service reports an error diff --git a/podman/domain/pods_manager.py b/podman/domain/pods_manager.py index 4f2f3ca9..e31c459b 100644 --- a/podman/domain/pods_manager.py +++ b/podman/domain/pods_manager.py @@ -3,6 +3,7 @@ import json import logging from typing import Any, Optional, Union +from collections.abc import Iterator from podman import api from podman.domain.manager import Manager @@ -11,6 +12,8 @@ logger = logging.getLogger("podman.pods") +builtin_list = list + class PodsManager(Manager): """Specialized Manager for Pod resources.""" @@ -129,7 +132,9 @@ def remove(self, pod_id: Union[Pod, str], force: Optional[bool] = None) -> None: response = self.client.delete(f"/pods/{pod_id}", params={"force": force}) response.raise_for_status() - def stats(self, **kwargs) -> Union[list[dict[str, Any]], [list[dict[str, Any]]]]: + def stats( + self, **kwargs + ) -> Union[builtin_list[dict[str, Any]], Iterator[builtin_list[dict[str, Any]]]]: """Resource usage statistics for the containers in pods. Keyword Args: diff --git a/podman/domain/secrets.py b/podman/domain/secrets.py index d56432b9..20c81ac8 100644 --- a/podman/domain/secrets.py +++ b/podman/domain/secrets.py @@ -80,7 +80,7 @@ def list(self, **kwargs) -> list[Secret]: """Report on Secrets. Keyword Args: - filters (Dict[str, Any]): Ignored. + filters (dict[str, Any]): Ignored. Raises: APIError: when error returned by service diff --git a/podman/domain/volumes.py b/podman/domain/volumes.py index 008a3c8c..213d15e8 100644 --- a/podman/domain/volumes.py +++ b/podman/domain/volumes.py @@ -53,8 +53,8 @@ def create(self, name: Optional[str] = None, **kwargs) -> Volume: Keyword Args: driver (str): Volume driver to use - driver_opts (Dict[str, str]): Options to use with driver - labels (Dict[str, str]): Labels to apply to volume + driver_opts (dict[str, str]): Options to use with driver + labels (dict[str, str]): Labels to apply to volume Raises: APIError: when service reports error diff --git a/podman/tests/unit/test_api_utils.py b/podman/tests/unit/test_api_utils.py index ea389143..0635bcd3 100644 --- a/podman/tests/unit/test_api_utils.py +++ b/podman/tests/unit/test_api_utils.py @@ -22,10 +22,10 @@ class TestCase: TestCase(name="empty str", input="", expected=None), TestCase(name="str", input="reference=fedora", expected='{"reference": ["fedora"]}'), TestCase( - name="List[str]", input=["reference=fedora"], expected='{"reference": ["fedora"]}' + name="list[str]", input=["reference=fedora"], expected='{"reference": ["fedora"]}' ), TestCase( - name="Dict[str,str]", + name="dict[str,str]", input={"reference": "fedora"}, expected='{"reference": ["fedora"]}', ),