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
8 changes: 4 additions & 4 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, 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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions cloudfoundry_client/v3/service_credential_bindings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING

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

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/v3/test_apps.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down
Loading