diff --git a/cloudfoundry_client/common_objects.py b/cloudfoundry_client/common_objects.py index f967c7b..71fe08b 100644 --- a/cloudfoundry_client/common_objects.py +++ b/cloudfoundry_client/common_objects.py @@ -1,5 +1,6 @@ import json -from typing import Callable, TypeVar, Generic +from collections.abc import Callable +from typing import TypeVar, Generic class Request(dict): diff --git a/cloudfoundry_client/doppler/websocket_envelope_reader.py b/cloudfoundry_client/doppler/websocket_envelope_reader.py index 1a2d77d..d4e63b3 100644 --- a/cloudfoundry_client/doppler/websocket_envelope_reader.py +++ b/cloudfoundry_client/doppler/websocket_envelope_reader.py @@ -1,5 +1,5 @@ import ssl -from typing import Callable, Tuple +from collections.abc import Callable import websocket @@ -12,7 +12,7 @@ def __init__( verify_ssl: bool = True, proxy_host: str | None = None, proxy_port: int | None = None, - proxy_auth: Tuple[str, str] | None = None, + proxy_auth: tuple[str, str] | None = None, ): if not verify_ssl: self._ws = websocket.WebSocket(sslopt=dict(cert_reqs=ssl.CERT_NONE)) diff --git a/cloudfoundry_client/main/apps_command_domain.py b/cloudfoundry_client/main/apps_command_domain.py index 3d946b8..206ae2e 100644 --- a/cloudfoundry_client/main/apps_command_domain.py +++ b/cloudfoundry_client/main/apps_command_domain.py @@ -1,5 +1,5 @@ from argparse import _SubParsersAction, Namespace -from typing import Callable +from collections.abc import Callable from cloudfoundry_client.client import CloudFoundryClient from cloudfoundry_client.main.command_domain import CommandDomain, Command diff --git a/cloudfoundry_client/main/command_domain.py b/cloudfoundry_client/main/command_domain.py index 06d9e46..0910975 100644 --- a/cloudfoundry_client/main/command_domain.py +++ b/cloudfoundry_client/main/command_domain.py @@ -4,8 +4,9 @@ import re from argparse import _SubParsersAction, Namespace from collections import OrderedDict +from collections.abc import Callable from http import HTTPStatus -from typing import Callable, Any +from typing import Any from cloudfoundry_client.client import CloudFoundryClient from cloudfoundry_client.errors import InvalidStatusCode diff --git a/cloudfoundry_client/main/main.py b/cloudfoundry_client/main/main.py index e8027b0..6d5b4b7 100644 --- a/cloudfoundry_client/main/main.py +++ b/cloudfoundry_client/main/main.py @@ -5,8 +5,9 @@ import os import re import sys +from collections.abc import Callable from http import HTTPStatus -from typing import Tuple, Callable, Any +from typing import Any from requests.exceptions import ConnectionError @@ -152,7 +153,7 @@ def _get_v2_client_domain(client: CloudFoundryClient, domain: str) -> Any: return getattr(client.v2, "%ss" % domain) -def generate_oauth_token_command() -> Tuple[Command, str]: +def generate_oauth_token_command() -> tuple[Command, str]: entry = "oauth-token" def generate_parser(parser: argparse._SubParsersAction): diff --git a/cloudfoundry_client/main/operation_commands.py b/cloudfoundry_client/main/operation_commands.py index 8ef39e1..89db16a 100644 --- a/cloudfoundry_client/main/operation_commands.py +++ b/cloudfoundry_client/main/operation_commands.py @@ -1,12 +1,11 @@ from argparse import _SubParsersAction, Namespace -from typing import Tuple from cloudfoundry_client.client import CloudFoundryClient from cloudfoundry_client.main.command_domain import Command from cloudfoundry_client.operations.push.push import PushOperation -def generate_push_command() -> Tuple[Command, str]: +def generate_push_command() -> tuple[Command, str]: entry = "push_app" def generate_parser(parser: _SubParsersAction): diff --git a/cloudfoundry_client/networking/entities.py b/cloudfoundry_client/networking/entities.py index 73a453b..6211de5 100644 --- a/cloudfoundry_client/networking/entities.py +++ b/cloudfoundry_client/networking/entities.py @@ -1,6 +1,7 @@ import logging +from collections.abc import Callable from functools import reduce -from typing import Callable, Tuple, Any, Generator, TYPE_CHECKING +from typing import Any, Generator, TYPE_CHECKING from urllib.parse import quote from requests import Response @@ -31,7 +32,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient", *args, ** raise InvalidEntity(**self) -EntityBuilder = Callable[[list[Tuple[str, Any]]], Entity] +EntityBuilder = Callable[[list[tuple[str, Any]]], Entity] class EntityManager(object): @@ -105,7 +106,7 @@ def _get_entity_builder(self, entity_builder: EntityBuilder | None) -> EntityBui return entity_builder def _get_url_filtered(self, url: str, **kwargs) -> str: - def _append_encoded_parameter(parameters: list[str], args: Tuple[str, Any]) -> list[str]: + def _append_encoded_parameter(parameters: list[str], args: tuple[str, Any]) -> list[str]: parameter_name, parameter_value = args[0], args[1] if parameter_name in self.list_query_parameters: parameters.append("%s=%s" % (parameter_name, str(parameter_value))) diff --git a/cloudfoundry_client/operations/push/file_helper.py b/cloudfoundry_client/operations/push/file_helper.py index 9f0afaa..30acdcc 100644 --- a/cloudfoundry_client/operations/push/file_helper.py +++ b/cloudfoundry_client/operations/push/file_helper.py @@ -2,7 +2,8 @@ import os import stat import zipfile -from typing import Callable, Generator, Tuple +from collections.abc import Callable +from typing import Generator class FileHelper(object): @@ -32,7 +33,7 @@ def unzip(path: str, tmp_dir: str): zip_ref.extract(entry, tmp_dir) @staticmethod - def walk(path: str) -> Generator[Tuple[str, list[str]], None, None]: + def walk(path: str) -> Generator[tuple[str, list[str]], None, None]: for dir_path, _, files in os.walk(path, topdown=True): yield dir_path[len(path) :].lstrip("/"), files diff --git a/cloudfoundry_client/operations/push/push.py b/cloudfoundry_client/operations/push/push.py index 53388ae..75de4cc 100644 --- a/cloudfoundry_client/operations/push/push.py +++ b/cloudfoundry_client/operations/push/push.py @@ -5,7 +5,6 @@ import shutil import tempfile import time -from typing import Tuple from cloudfoundry_client.client import CloudFoundryClient from cloudfoundry_client.operations.push.cf_ignore import CfIgnore @@ -32,7 +31,7 @@ def push(self, space_id: str, manifest_path: str, restart: bool = True): if "path" in app_manifest or "docker" in app_manifest: self._push_application(organization, space, app_manifest, restart) - def _retrieve_space_and_organization(self, space_id: str) -> Tuple[Entity, Entity]: + def _retrieve_space_and_organization(self, space_id: str) -> tuple[Entity, Entity]: space = self.client.v2.spaces.get(space_id) organization = space.organization() return organization, space @@ -211,7 +210,7 @@ def _resolve_new_tcp_route(self, space: Entity, domain: Entity, port: int) -> En return existing_route @staticmethod - def _split_route(requested_route: dict[str, str]) -> Tuple[str, int, str]: + def _split_route(requested_route: dict[str, str]) -> tuple[str, int, str]: route_splitted = PushOperation.SPLIT_ROUTE_PATTERN.match(requested_route["route"]) if route_splitted is None: raise AssertionError("Invalid route: %s" % requested_route["route"]) @@ -223,7 +222,7 @@ def _split_route(requested_route: dict[str, str]) -> Tuple[str, int, str]: @staticmethod def _resolve_domain( route: str, private_domains: dict[str, Entity], shared_domains: dict[str, Entity] - ) -> Tuple[str, str, Entity]: + ) -> tuple[str, str, Entity]: for domains in [private_domains, shared_domains]: if route in domains: return "", route, domains[route] diff --git a/cloudfoundry_client/v2/entities.py b/cloudfoundry_client/v2/entities.py index 5196dd2..e71440e 100644 --- a/cloudfoundry_client/v2/entities.py +++ b/cloudfoundry_client/v2/entities.py @@ -1,5 +1,6 @@ +from collections.abc import Callable from functools import partial, reduce -from typing import Callable, Tuple, Any, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from urllib.parse import quote from requests import Response @@ -39,7 +40,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient", *args, ** raise InvalidEntity(**self) -EntityBuilder = Callable[[list[Tuple[str, Any]]], Entity] +EntityBuilder = Callable[[list[tuple[str, Any]]], Entity] class EntityManager(object): @@ -141,7 +142,7 @@ def _get_entity_builder(self, entity_builder: EntityBuilder | None) -> EntityBui return entity_builder def _get_url_filtered(self, url: str, **kwargs) -> str: - def _append_encoded_parameter(parameters: list[str], args: Tuple[str, Any]) -> list[str]: + def _append_encoded_parameter(parameters: list[str], args: tuple[str, Any]) -> list[str]: parameter_name, parameter_value = args[0], args[1] if parameter_name in self.list_query_parameters: parameters.append("%s=%s" % (parameter_name, str(parameter_value))) diff --git a/cloudfoundry_client/v3/entities.py b/cloudfoundry_client/v3/entities.py index 6c4c55e..6ddacd8 100644 --- a/cloudfoundry_client/v3/entities.py +++ b/cloudfoundry_client/v3/entities.py @@ -1,6 +1,7 @@ import functools +from collections.abc import Callable from json import JSONDecodeError -from typing import Any, Tuple, TypeVar, TYPE_CHECKING, Callable, Type +from typing import Any, TypeVar, TYPE_CHECKING, Type from urllib.parse import quote, urlparse from requests import Response @@ -296,7 +297,7 @@ def _entity(self, result: JsonObject, entity_type: ENTITY_TYPE | None) -> JsonOb @staticmethod def _get_url_with_encoded_params(url: str, **kwargs) -> str: - def _append_encoded_parameter(parameters: list[str], args: Tuple[str, Any]) -> list[str]: + def _append_encoded_parameter(parameters: list[str], args: tuple[str, Any]) -> list[str]: parameter_name, parameter_value = args[0], args[1] if isinstance(parameter_value, (list, tuple)): parameters.append("%s=%s" % (parameter_name, quote(",".join(parameter_value))))