Skip to content

Commit 29e7bba

Browse files
authored
chore(code) remove Union (#273)
1 parent d9c547f commit 29e7bba

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

cloudfoundry_client/v3/entities.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import functools
22
from json import JSONDecodeError
3-
from typing import Any, List, Tuple, Union, TypeVar, TYPE_CHECKING, Callable, Type
3+
from typing import Any, List, Tuple, TypeVar, TYPE_CHECKING, Callable, Type
44
from urllib.parse import quote, urlparse
55

66
from requests import Response
@@ -171,7 +171,7 @@ def _list(self, requested_path: str, entity_type: ENTITY_TYPE | None = None, **k
171171
return self._pagination(response_json, entity_type)
172172

173173
def _attempt_to_paginate(self, url_requested: str, entity_type: ENTITY_TYPE | None = None) \
174-
-> Union[Pagination[Entity], Entity]:
174+
-> Pagination[Entity] | Entity:
175175
response_json = self._read_response(self.client.get(url_requested), JsonObject)
176176
if "resources" in response_json:
177177
return self._pagination(response_json, entity_type)
@@ -246,7 +246,7 @@ def get(self, entity_id: str, *extra_paths, **kwargs) -> Entity:
246246
requested_path = "%s%s/%s/%s" % (self.target_endpoint, self.entity_uri, entity_id, "/".join(extra_paths))
247247
return self._get(requested_path, **kwargs)
248248

249-
def _read_response(self, response: Response, entity_type: ENTITY_TYPE | None) -> Union[JsonObject, Entity]:
249+
def _read_response(self, response: Response, entity_type: ENTITY_TYPE | None) -> JsonObject | Entity:
250250
try:
251251
result = response.json(object_pairs_hook=JsonObject)
252252
except JSONDecodeError:
@@ -288,7 +288,7 @@ def _include_resources(self, resource: JsonObject, result: JsonObject) -> None:
288288
def _get_entity_type(entity_name: str) -> Type[ENTITY_TYPE]:
289289
return Entity
290290

291-
def _entity(self, result: JsonObject, entity_type: ENTITY_TYPE | None) -> Union[JsonObject, Entity]:
291+
def _entity(self, result: JsonObject, entity_type: ENTITY_TYPE | None) -> JsonObject | Entity:
292292
if "guid" in result or ("links" in result and "job" in result["links"]):
293293
return (entity_type or self.entity_type)(self.target_endpoint, self.client, **result)
294294
else:

cloudfoundry_client/v3/service_credential_bindings.py

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

33
from cloudfoundry_client.v3.entities import EntityManager, Entity, ToOneRelationship
44

@@ -21,7 +21,7 @@ def create(
2121
meta_labels: dict | None,
2222
meta_annotations: dict | None,
2323
asynchronous: bool = True,
24-
) -> Union[str, Entity, None]:
24+
) -> str | Entity | None:
2525
data = {
2626
"name": name,
2727
"type": service_credential_binding_type,

tests/v3/test_apps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import yaml
33
from http import HTTPStatus
4-
from typing import List, Union
4+
from typing import List
55

66
from abstract_test_case import AbstractTestCase
77
from cloudfoundry_client.common_objects import JsonObject, Pagination
@@ -153,7 +153,7 @@ def test_get_manifest(self):
153153
self.assertIsInstance(application_services, list)
154154
self.assertEqual(len(application_services), 1)
155155
self.assertEqual(application_services[0], "my-service")
156-
application_routes: List[Union[dict, str]] | None = application.get("routes")
156+
application_routes: List[dict | str] | None = application.get("routes")
157157
self.assertIsInstance(application_routes, list)
158158
self.assertEqual(len(application_routes), 1)
159159
application_route: dict = application_routes[0]

0 commit comments

Comments
 (0)