Skip to content

Commit 257fe66

Browse files
authored
chore(code) remove List (#274)
1 parent 29e7bba commit 257fe66

File tree

15 files changed

+38
-41
lines changed

15 files changed

+38
-41
lines changed

cloudfoundry_client/common_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from typing import Callable, TypeVar, Generic, List
2+
from typing import Callable, TypeVar, Generic
33

44

55
class Request(dict):
@@ -22,7 +22,7 @@ class Pagination(Generic[ENTITY]):
2222
def __init__(self, first_page: JsonObject,
2323
total_result: int,
2424
next_page_loader: Callable[[JsonObject], JsonObject | None],
25-
resources_accessor: Callable[[JsonObject], List[JsonObject]],
25+
resources_accessor: Callable[[JsonObject], list[JsonObject]],
2626
instance_creator: Callable[[JsonObject], ENTITY]):
2727
self._first_page = first_page
2828
self._total_results = total_result

cloudfoundry_client/main/command_domain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from argparse import _SubParsersAction, Namespace
66
from collections import OrderedDict
77
from http import HTTPStatus
8-
from typing import Callable, Any, List
8+
from typing import Callable, Any
99

1010
from cloudfoundry_client.client import CloudFoundryClient
1111
from cloudfoundry_client.errors import InvalidStatusCode
@@ -60,7 +60,7 @@ def __init__(
6060
self.commands[command[0].entry] = command[0]
6161
self.extra_description[command[0].entry] = command[1]
6262

63-
def description(self) -> List[str]:
63+
def description(self) -> list[str]:
6464
description = [
6565
" %s" % self.display_name,
6666
" %s : List %ss" % (self._list_entry(), self.entity_name),

cloudfoundry_client/networking/entities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from functools import reduce
3-
from typing import Callable, List, Tuple, Any, Generator, TYPE_CHECKING
3+
from typing import Callable, Tuple, Any, Generator, TYPE_CHECKING
44
from urllib.parse import quote
55

66
from requests import Response
@@ -31,7 +31,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient", *args, **
3131
raise InvalidEntity(**self)
3232

3333

34-
EntityBuilder = Callable[[List[Tuple[str, Any]]], Entity]
34+
EntityBuilder = Callable[[list[Tuple[str, Any]]], Entity]
3535

3636

3737
class EntityManager(object):
@@ -105,7 +105,7 @@ def _get_entity_builder(self, entity_builder: EntityBuilder | None) -> EntityBui
105105
return entity_builder
106106

107107
def _get_url_filtered(self, url: str, **kwargs) -> str:
108-
def _append_encoded_parameter(parameters: List[str], args: Tuple[str, Any]) -> List[str]:
108+
def _append_encoded_parameter(parameters: list[str], args: Tuple[str, Any]) -> list[str]:
109109
parameter_name, parameter_value = args[0], args[1]
110110
if parameter_name in self.list_query_parameters:
111111
parameters.append("%s=%s" % (parameter_name, str(parameter_value)))

cloudfoundry_client/networking/v1/external/policies.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
from cloudfoundry_client.networking.entities import EntityManager
3-
from typing import List
43

54
_logger = logging.getLogger(__name__)
65

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

48-
def create(self, policies: List[Policy]):
47+
def create(self, policies: list[Policy]):
4948
"""create a new network policy
5049
5150
Responses:
@@ -62,7 +61,7 @@ def create(self, policies: List[Policy]):
6261
data.append(policy.dump())
6362
return super(PolicyManager, self)._create({"policies": data})
6463

65-
def delete(self, policies: List[Policy]):
64+
def delete(self, policies: list[Policy]):
6665
"""remove a new network policy
6766
6867
Responses:

cloudfoundry_client/operations/push/cf_ignore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fnmatch
22
import logging
33
import os
4-
from typing import List
54

65
_logger = logging.getLogger(__name__)
76

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

2827
@staticmethod
29-
def _pattern(pattern: str) -> List[str]:
28+
def _pattern(pattern: str) -> list[str]:
3029
if pattern.find("/") < 0:
3130
return [pattern, os.path.join("**", pattern)]
3231
elif pattern.endswith("/"):

cloudfoundry_client/operations/push/file_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import stat
44
import zipfile
5-
from typing import Callable, Generator, Tuple, List
5+
from typing import Callable, Generator, Tuple
66

77

88
class FileHelper(object):
@@ -32,7 +32,7 @@ def unzip(path: str, tmp_dir: str):
3232
zip_ref.extract(entry, tmp_dir)
3333

3434
@staticmethod
35-
def walk(path: str) -> Generator[Tuple[str, List[str]], None, None]:
35+
def walk(path: str) -> Generator[Tuple[str, list[str]], None, None]:
3636
for dir_path, _, files in os.walk(path, topdown=True):
3737
yield dir_path[len(path) :].lstrip("/"), files
3838

cloudfoundry_client/operations/push/push.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import shutil
66
import tempfile
77
import time
8-
from typing import Tuple, List, Dict
8+
from typing import Tuple, Dict
99

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

107107
def _route_application(
108-
self, organization: Entity, space: Entity, app: Entity, no_route: bool, routes: List[str], random_route: bool
108+
self, organization: Entity, space: Entity, app: Entity, no_route: bool, routes: list[str], random_route: bool
109109
):
110110
existing_routes = [route for route in app.routes()]
111111
if no_route:
@@ -115,7 +115,7 @@ def _route_application(
115115
else:
116116
self._build_new_requested_routes(organization, space, app, existing_routes, routes)
117117

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

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

144144
def _build_new_requested_routes(
145-
self, organization: Entity, space: Entity, app: Entity, existing_routes: List[Entity], requested_routes: List[str]
145+
self, organization: Entity, space: Entity, app: Entity, existing_routes: list[Entity], requested_routes: list[str]
146146
):
147147
private_domains = {domain["entity"]["name"]: domain for domain in organization.private_domains()}
148148
shared_domains = {domain["entity"]["name"]: domain for domain in self.client.v2.shared_domains.list()}
@@ -310,7 +310,7 @@ def _load_all_resources(top_directory: str) -> dict:
310310
)
311311
return application_items
312312

313-
def _bind_services(self, space: Entity, app: Entity, services: List[str]):
313+
def _bind_services(self, space: Entity, app: Entity, services: list[str]):
314314
service_instances = [
315315
service_instance for service_instance in space.service_instances(return_user_provided_service_instances="true")
316316
]

cloudfoundry_client/v2/entities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import partial, reduce
2-
from typing import Callable, List, Tuple, Any, TYPE_CHECKING
2+
from typing import Callable, Tuple, Any, TYPE_CHECKING
33
from urllib.parse import quote
44
from requests import Response
55

@@ -39,7 +39,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient", *args, **
3939
raise InvalidEntity(**self)
4040

4141

42-
EntityBuilder = Callable[[List[Tuple[str, Any]]], Entity]
42+
EntityBuilder = Callable[[list[Tuple[str, Any]]], Entity]
4343

4444

4545
class EntityManager(object):
@@ -141,7 +141,7 @@ def _get_entity_builder(self, entity_builder: EntityBuilder | None) -> EntityBui
141141
return entity_builder
142142

143143
def _get_url_filtered(self, url: str, **kwargs) -> str:
144-
def _append_encoded_parameter(parameters: List[str], args: Tuple[str, Any]) -> List[str]:
144+
def _append_encoded_parameter(parameters: list[str], args: Tuple[str, Any]) -> list[str]:
145145
parameter_name, parameter_value = args[0], args[1]
146146
if parameter_name in self.list_query_parameters:
147147
parameters.append("%s=%s" % (parameter_name, str(parameter_value)))

cloudfoundry_client/v2/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, TYPE_CHECKING
1+
from typing import TYPE_CHECKING
22

33
from cloudfoundry_client.common_objects import JsonObject
44

@@ -11,6 +11,6 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
1111
self.target_endpoint = target_endpoint
1212
self.client = client
1313

14-
def match(self, items: List[dict]) -> List[JsonObject]:
14+
def match(self, items: list[dict]) -> list[JsonObject]:
1515
response = self.client.put("%s/v2/resource_match" % self.client.info.api_endpoint, json=items)
1616
return response.json(object_pairs_hook=JsonObject)

cloudfoundry_client/v2/service_instances.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Dict, TYPE_CHECKING
1+
from typing import Dict, TYPE_CHECKING
22

33
from cloudfoundry_client.v2.entities import EntityManager, Entity
44

@@ -18,7 +18,7 @@ def create(
1818
instance_name: str,
1919
plan_guid: str,
2020
parameters: dict | None = None,
21-
tags: List[str] = None,
21+
tags: list[str] = None,
2222
accepts_incomplete: bool | None = False,
2323
) -> Entity:
2424
request = self._request(name=instance_name, space_guid=space_guid, service_plan_guid=plan_guid)
@@ -33,7 +33,7 @@ def update(
3333
instance_name: str | None = None,
3434
plan_guid: str | None = None,
3535
parameters: dict | None = None,
36-
tags: List[str] = None,
36+
tags: list[str] = None,
3737
accepts_incomplete: bool | None = False,
3838
) -> Entity:
3939
request = self._request()

0 commit comments

Comments
 (0)