Skip to content

Commit febba7b

Browse files
committed
Fix non aiohttp installation
1 parent 3629d68 commit febba7b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

valo_api/endpoint.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
from valo_api.exceptions.valo_api_exception import ValoAPIException
2323
from valo_api.responses.error_response import ErrorResponse
2424
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
2631

2732
R = TypeVar("R")
2833

@@ -51,11 +56,16 @@ def endpoint_wrappers(
5156
) -> Iterable[Tuple[str, Callable[..., Union[R, Awaitable[R]]]]]:
5257
for version in self.versions:
5358
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+
)
5763
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+
)
5969

6070
def _get_endpoint_wrapper(
6171
self, version: Optional[str] = None, async_function: bool = False

0 commit comments

Comments
 (0)