diff --git a/cloudfoundry_client/v3/entities.py b/cloudfoundry_client/v3/entities.py index de4b8b4..64f4d64 100644 --- a/cloudfoundry_client/v3/entities.py +++ b/cloudfoundry_client/v3/entities.py @@ -1,6 +1,6 @@ import functools from json import JSONDecodeError -from typing import Any, List, Tuple, Union, TypeVar, TYPE_CHECKING, Callable, Type +from typing import Any, List, Tuple, TypeVar, TYPE_CHECKING, Callable, Type from urllib.parse import quote, urlparse from requests import Response @@ -171,7 +171,7 @@ def _list(self, requested_path: str, entity_type: ENTITY_TYPE | None = None, **k return self._pagination(response_json, entity_type) def _attempt_to_paginate(self, url_requested: str, entity_type: ENTITY_TYPE | None = None) \ - -> Union[Pagination[Entity], Entity]: + -> Pagination[Entity] | Entity: response_json = self._read_response(self.client.get(url_requested), JsonObject) if "resources" in response_json: return self._pagination(response_json, entity_type) @@ -246,7 +246,7 @@ def get(self, entity_id: str, *extra_paths, **kwargs) -> Entity: requested_path = "%s%s/%s/%s" % (self.target_endpoint, self.entity_uri, entity_id, "/".join(extra_paths)) return self._get(requested_path, **kwargs) - def _read_response(self, response: Response, entity_type: ENTITY_TYPE | None) -> Union[JsonObject, Entity]: + def _read_response(self, response: Response, entity_type: ENTITY_TYPE | None) -> JsonObject | Entity: try: result = response.json(object_pairs_hook=JsonObject) except JSONDecodeError: @@ -288,7 +288,7 @@ def _include_resources(self, resource: JsonObject, result: JsonObject) -> None: def _get_entity_type(entity_name: str) -> Type[ENTITY_TYPE]: return Entity - def _entity(self, result: JsonObject, entity_type: ENTITY_TYPE | None) -> Union[JsonObject, Entity]: + def _entity(self, result: JsonObject, entity_type: ENTITY_TYPE | None) -> JsonObject | Entity: if "guid" in result or ("links" in result and "job" in result["links"]): return (entity_type or self.entity_type)(self.target_endpoint, self.client, **result) else: diff --git a/cloudfoundry_client/v3/service_credential_bindings.py b/cloudfoundry_client/v3/service_credential_bindings.py index b380b90..ff41c00 100644 --- a/cloudfoundry_client/v3/service_credential_bindings.py +++ b/cloudfoundry_client/v3/service_credential_bindings.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Union +from typing import TYPE_CHECKING from cloudfoundry_client.v3.entities import EntityManager, Entity, ToOneRelationship @@ -21,7 +21,7 @@ def create( meta_labels: dict | None, meta_annotations: dict | None, asynchronous: bool = True, - ) -> Union[str, Entity, None]: + ) -> str | Entity | None: data = { "name": name, "type": service_credential_binding_type, diff --git a/tests/v3/test_apps.py b/tests/v3/test_apps.py index 3b51108..2ce85d2 100644 --- a/tests/v3/test_apps.py +++ b/tests/v3/test_apps.py @@ -1,7 +1,7 @@ import unittest import yaml from http import HTTPStatus -from typing import List, Union +from typing import List from abstract_test_case import AbstractTestCase from cloudfoundry_client.common_objects import JsonObject, Pagination @@ -153,7 +153,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[Union[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]