Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cloudfoundry_client/common_objects.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions cloudfoundry_client/doppler/websocket_envelope_reader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ssl
from typing import Callable, Tuple
from collections.abc import Callable

import websocket

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/main/apps_command_domain.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion cloudfoundry_client/main/command_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cloudfoundry_client/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions cloudfoundry_client/main/operation_commands.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
7 changes: 4 additions & 3 deletions cloudfoundry_client/networking/entities.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)))
Expand Down
5 changes: 3 additions & 2 deletions cloudfoundry_client/operations/push/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions cloudfoundry_client/operations/push/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"])
Expand All @@ -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]
Expand Down
7 changes: 4 additions & 3 deletions cloudfoundry_client/v2/entities.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)))
Expand Down
5 changes: 3 additions & 2 deletions cloudfoundry_client/v3/entities.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))))
Expand Down
Loading