|
22 | 22 | from valo_api.exceptions.valo_api_exception import ValoAPIException |
23 | 23 | from valo_api.responses.error_response import ErrorResponse |
24 | 24 | from valo_api.utils.dict_struct import DictStruct |
25 | | -from valo_api.utils.fetch_endpoint import fetch_endpoint, fetch_endpoint_async |
| 25 | +from valo_api.utils.fetch_endpoint import fetch_endpoint |
| 26 | + |
| 27 | +try: |
| 28 | + from valo_api.utils.fetch_endpoint import fetch_endpoint_async |
| 29 | +except ImportError: |
| 30 | + pass |
26 | 31 |
|
27 | 32 | R = TypeVar("R") |
28 | 33 |
|
@@ -51,11 +56,16 @@ def endpoint_wrappers( |
51 | 56 | ) -> Iterable[Tuple[str, Callable[..., Union[R, Awaitable[R]]]]]: |
52 | 57 | for version in self.versions: |
53 | 58 | yield f"{self.f_name}_{version}", self._get_endpoint_wrapper(version) |
54 | | - yield f"{self.f_name}_{version}_async", self._get_endpoint_wrapper( |
55 | | - version, True |
56 | | - ) |
| 59 | + if "fetch_endpoint_async" in globals(): |
| 60 | + yield f"{self.f_name}_{version}_async", self._get_endpoint_wrapper( |
| 61 | + version, True |
| 62 | + ) |
57 | 63 | yield self.f_name, self._get_endpoint_wrapper() |
58 | | - yield f"{self.f_name}_async", self._get_endpoint_wrapper(async_function=True) |
| 64 | + |
| 65 | + if "fetch_endpoint_async" in globals(): |
| 66 | + yield f"{self.f_name}_async", self._get_endpoint_wrapper( |
| 67 | + async_function=True |
| 68 | + ) |
59 | 69 |
|
60 | 70 | def _get_endpoint_wrapper( |
61 | 71 | self, version: Optional[str] = None, async_function: bool = False |
|
0 commit comments