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
4 changes: 2 additions & 2 deletions cloudfoundry_client/common_objects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import Callable, TypeVar, Generic, List
from typing import Callable, TypeVar, Generic


class Request(dict):
Expand All @@ -22,7 +22,7 @@ class Pagination(Generic[ENTITY]):
def __init__(self, first_page: JsonObject,
total_result: int,
next_page_loader: Callable[[JsonObject], JsonObject | None],
resources_accessor: Callable[[JsonObject], List[JsonObject]],
resources_accessor: Callable[[JsonObject], list[JsonObject]],
instance_creator: Callable[[JsonObject], ENTITY]):
self._first_page = first_page
self._total_results = total_result
Expand Down
4 changes: 2 additions & 2 deletions cloudfoundry_client/main/command_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from argparse import _SubParsersAction, Namespace
from collections import OrderedDict
from http import HTTPStatus
from typing import Callable, Any, List
from typing import Callable, Any

from cloudfoundry_client.client import CloudFoundryClient
from cloudfoundry_client.errors import InvalidStatusCode
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(
self.commands[command[0].entry] = command[0]
self.extra_description[command[0].entry] = command[1]

def description(self) -> List[str]:
def description(self) -> list[str]:
description = [
" %s" % self.display_name,
" %s : List %ss" % (self._list_entry(), self.entity_name),
Expand Down
6 changes: 3 additions & 3 deletions cloudfoundry_client/networking/entities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import reduce
from typing import Callable, List, Tuple, Any, Generator, TYPE_CHECKING
from typing import Callable, Tuple, Any, Generator, TYPE_CHECKING
from urllib.parse import quote

from requests import Response
Expand Down Expand Up @@ -31,7 +31,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 +105,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: 2 additions & 3 deletions cloudfoundry_client/networking/v1/external/policies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from cloudfoundry_client.networking.entities import EntityManager
from typing import List

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -45,7 +44,7 @@ class PolicyManager(EntityManager):
def __init__(self, target_endpoint, client):
super(PolicyManager, self).__init__(target_endpoint, client, "/networking/v1/external/policies")

def create(self, policies: List[Policy]):
def create(self, policies: list[Policy]):
"""create a new network policy

Responses:
Expand All @@ -62,7 +61,7 @@ def create(self, policies: List[Policy]):
data.append(policy.dump())
return super(PolicyManager, self)._create({"policies": data})

def delete(self, policies: List[Policy]):
def delete(self, policies: list[Policy]):
"""remove a new network policy

Responses:
Expand Down
3 changes: 1 addition & 2 deletions cloudfoundry_client/operations/push/cf_ignore.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fnmatch
import logging
import os
from typing import List

_logger = logging.getLogger(__name__)

Expand All @@ -26,7 +25,7 @@ def is_relative_file_ignored(cf_ignore_entry):
return any([is_relative_file_ignored(ignore_item) for ignore_item in self.ignore_items])

@staticmethod
def _pattern(pattern: str) -> List[str]:
def _pattern(pattern: str) -> list[str]:
if pattern.find("/") < 0:
return [pattern, os.path.join("**", pattern)]
elif pattern.endswith("/"):
Expand Down
4 changes: 2 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,7 @@
import os
import stat
import zipfile
from typing import Callable, Generator, Tuple, List
from typing import Callable, Generator, Tuple


class FileHelper(object):
Expand Down Expand Up @@ -32,7 +32,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
10 changes: 5 additions & 5 deletions cloudfoundry_client/operations/push/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shutil
import tempfile
import time
from typing import Tuple, List, Dict
from typing import Tuple, Dict

from cloudfoundry_client.client import CloudFoundryClient
from cloudfoundry_client.operations.push.cf_ignore import CfIgnore
Expand Down Expand Up @@ -105,7 +105,7 @@ def _merge_environment(app: Entity | None, app_manifest: dict) -> dict:
return environment

def _route_application(
self, organization: Entity, space: Entity, app: Entity, no_route: bool, routes: List[str], random_route: bool
self, organization: Entity, space: Entity, app: Entity, no_route: bool, routes: list[str], random_route: bool
):
existing_routes = [route for route in app.routes()]
if no_route:
Expand All @@ -115,7 +115,7 @@ def _route_application(
else:
self._build_new_requested_routes(organization, space, app, existing_routes, routes)

def _remove_all_routes(self, app: Entity, routes: List[Entity]):
def _remove_all_routes(self, app: Entity, routes: list[Entity]):
for route in routes:
self.client.v2.apps.remove_route(app["metadata"]["guid"], route["metadata"]["guid"])

Expand All @@ -142,7 +142,7 @@ def _build_default_route(self, space: Entity, app: Entity, random_route: bool):
self.client.v2.apps.associate_route(app["metadata"]["guid"], route["metadata"]["guid"])

def _build_new_requested_routes(
self, organization: Entity, space: Entity, app: Entity, existing_routes: List[Entity], requested_routes: List[str]
self, organization: Entity, space: Entity, app: Entity, existing_routes: list[Entity], requested_routes: list[str]
):
private_domains = {domain["entity"]["name"]: domain for domain in organization.private_domains()}
shared_domains = {domain["entity"]["name"]: domain for domain in self.client.v2.shared_domains.list()}
Expand Down Expand Up @@ -310,7 +310,7 @@ def _load_all_resources(top_directory: str) -> dict:
)
return application_items

def _bind_services(self, space: Entity, app: Entity, services: List[str]):
def _bind_services(self, space: Entity, app: Entity, services: list[str]):
service_instances = [
service_instance for service_instance in space.service_instances(return_user_provided_service_instances="true")
]
Expand Down
6 changes: 3 additions & 3 deletions cloudfoundry_client/v2/entities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import partial, reduce
from typing import Callable, List, Tuple, Any, TYPE_CHECKING
from typing import Callable, Tuple, Any, TYPE_CHECKING
from urllib.parse import quote
from requests import Response

Expand Down Expand Up @@ -39,7 +39,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 +141,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
4 changes: 2 additions & 2 deletions cloudfoundry_client/v2/resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, TYPE_CHECKING
from typing import TYPE_CHECKING

from cloudfoundry_client.common_objects import JsonObject

Expand All @@ -11,6 +11,6 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
self.target_endpoint = target_endpoint
self.client = client

def match(self, items: List[dict]) -> List[JsonObject]:
def match(self, items: list[dict]) -> list[JsonObject]:
response = self.client.put("%s/v2/resource_match" % self.client.info.api_endpoint, json=items)
return response.json(object_pairs_hook=JsonObject)
6 changes: 3 additions & 3 deletions cloudfoundry_client/v2/service_instances.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, TYPE_CHECKING
from typing import Dict, TYPE_CHECKING

from cloudfoundry_client.v2.entities import EntityManager, Entity

Expand All @@ -18,7 +18,7 @@ def create(
instance_name: str,
plan_guid: str,
parameters: dict | None = None,
tags: List[str] = None,
tags: list[str] = None,
accepts_incomplete: bool | None = False,
) -> Entity:
request = self._request(name=instance_name, space_guid=space_guid, service_plan_guid=plan_guid)
Expand All @@ -33,7 +33,7 @@ def update(
instance_name: str | None = None,
plan_guid: str | None = None,
parameters: dict | None = None,
tags: List[str] = None,
tags: list[str] = None,
accepts_incomplete: bool | None = False,
) -> Entity:
request = self._request()
Expand Down
4 changes: 2 additions & 2 deletions cloudfoundry_client/v3/entities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
from json import JSONDecodeError
from typing import Any, List, Tuple, TypeVar, TYPE_CHECKING, Callable, Type
from typing import Any, Tuple, TypeVar, TYPE_CHECKING, Callable, Type
from urllib.parse import quote, urlparse

from requests import Response
Expand Down Expand Up @@ -296,7 +296,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
8 changes: 4 additions & 4 deletions cloudfoundry_client/v3/security_groups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, asdict
from enum import Enum, auto
from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING

from cloudfoundry_client.v3.entities import EntityManager, ToManyRelationship, Entity, ToOneRelationship

Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):

def create(self,
name: str,
rules: List[Rule] | None = None,
rules: list[Rule] | None = None,
globally_enabled: GloballyEnabled | None = None,
staging_spaces: ToManyRelationship | None = None,
running_spaces: ToManyRelationship | None = None) -> Entity:
Expand All @@ -51,7 +51,7 @@ def create(self,
def update(self,
security_group_id: str,
name: str | None = None,
rules: List[Rule] | None = None,
rules: list[Rule] | None = None,
globally_enabled: GloballyEnabled | None = None,
staging_spaces: ToManyRelationship | None = None,
running_spaces: ToManyRelationship | None = None) -> Entity:
Expand Down Expand Up @@ -91,7 +91,7 @@ def _unbind_space(self, security_group_id: str, space_guid: ToOneRelationship, r

@staticmethod
def _generate_payload(name: str | None,
rules: List[Rule] | None,
rules: list[Rule] | None,
globally_enabled: GloballyEnabled | None,
staging_spaces: ToManyRelationship | None,
running_spaces: ToManyRelationship | None):
Expand Down
6 changes: 3 additions & 3 deletions cloudfoundry_client/v3/service_instances.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, List
from typing import TYPE_CHECKING

from cloudfoundry_client.common_objects import JsonObject
from cloudfoundry_client.v3.entities import Entity, EntityManager, ToOneRelationship
Expand All @@ -19,7 +19,7 @@ def create(
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
parameters: dict | None = None,
tags: List[str] | None = None,
tags: list[str] | None = None,
) -> Entity:
data = {
"name": name,
Expand Down Expand Up @@ -48,7 +48,7 @@ def update(
maintenance_info: str | None = None,
meta_labels: dict | None = None,
meta_annotations: dict | None = None,
tags: List[str] | None = None
tags: list[str] | None = None
) -> Entity:
data = {}
if name:
Expand Down
6 changes: 3 additions & 3 deletions cloudfoundry_client/v3/service_plans.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, TYPE_CHECKING
from typing import Dict, TYPE_CHECKING

from cloudfoundry_client.v3.entities import EntityManager, Entity

Expand Down Expand Up @@ -32,7 +32,7 @@ def get_visibility(self, service_plan_guid: str) -> Dict:

# Updates a service plan visibility. It behaves similar to the POST service plan visibility endpoint but
# this endpoint will REPLACE the existing list of organizations when the service plan is organization visible.
def update_visibility(self, service_plan_guid: str, type: str, organizations: List[dict] | None = None) -> Dict:
def update_visibility(self, service_plan_guid: str, type: str, organizations: list[dict] | None = None) -> Dict:
payload = {"type": type}
if organizations:
payload["organizations"] = organizations
Expand All @@ -42,7 +42,7 @@ def update_visibility(self, service_plan_guid: str, type: str, organizations: Li

# Applies a service plan visibility. It behaves similar to the PATCH service plan visibility endpoint but
# this endpoint will APPEND to the existing list of organizations when the service plan is organization visible.
def apply_visibility_to_extra_orgs(self, service_plan_guid: str, organizations: List[dict]) -> Dict:
def apply_visibility_to_extra_orgs(self, service_plan_guid: str, organizations: list[dict]) -> Dict:
payload = {"type": "organization", "organizations": organizations}
return super(ServicePlanManager, self)._post(
url=f"{self.target_endpoint}{self.entity_uri}/{service_plan_guid}/visibility", data=payload, files=None
Expand Down
3 changes: 1 addition & 2 deletions tests/v3/test_apps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import unittest
import yaml
from http import HTTPStatus
from typing import List

from abstract_test_case import AbstractTestCase
from cloudfoundry_client.common_objects import JsonObject, Pagination
Expand Down Expand Up @@ -153,7 +152,7 @@ def test_get_manifest(self):
self.assertIsInstance(application_services, list)
self.assertEqual(len(application_services), 1)
self.assertEqual(application_services[0], "my-service")
application_routes: List[dict | str] | None = application.get("routes")
application_routes: list[dict | str] | None = application.get("routes")
self.assertIsInstance(application_routes, list)
self.assertEqual(len(application_routes), 1)
application_route: dict = application_routes[0]
Expand Down
Loading