|
1 | 1 | import functools |
2 | 2 | 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 |
4 | 4 | from urllib.parse import quote, urlparse |
5 | 5 |
|
6 | 6 | from requests import Response |
@@ -171,7 +171,7 @@ def _list(self, requested_path: str, entity_type: ENTITY_TYPE | None = None, **k |
171 | 171 | return self._pagination(response_json, entity_type) |
172 | 172 |
|
173 | 173 | def _attempt_to_paginate(self, url_requested: str, entity_type: ENTITY_TYPE | None = None) \ |
174 | | - -> Union[Pagination[Entity], Entity]: |
| 174 | + -> Pagination[Entity] | Entity: |
175 | 175 | response_json = self._read_response(self.client.get(url_requested), JsonObject) |
176 | 176 | if "resources" in response_json: |
177 | 177 | return self._pagination(response_json, entity_type) |
@@ -246,7 +246,7 @@ def get(self, entity_id: str, *extra_paths, **kwargs) -> Entity: |
246 | 246 | requested_path = "%s%s/%s/%s" % (self.target_endpoint, self.entity_uri, entity_id, "/".join(extra_paths)) |
247 | 247 | return self._get(requested_path, **kwargs) |
248 | 248 |
|
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: |
250 | 250 | try: |
251 | 251 | result = response.json(object_pairs_hook=JsonObject) |
252 | 252 | except JSONDecodeError: |
@@ -288,7 +288,7 @@ def _include_resources(self, resource: JsonObject, result: JsonObject) -> None: |
288 | 288 | def _get_entity_type(entity_name: str) -> Type[ENTITY_TYPE]: |
289 | 289 | return Entity |
290 | 290 |
|
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: |
292 | 292 | if "guid" in result or ("links" in result and "job" in result["links"]): |
293 | 293 | return (entity_type or self.entity_type)(self.target_endpoint, self.client, **result) |
294 | 294 | else: |
|
0 commit comments