1
Fork 0
mirror of https://github.com/RGBCube/GitHubWrapper synced 2025-05-30 20:48:12 +00:00

make latency an async method and fix typing

This commit is contained in:
RGBCube 2022-06-25 16:02:27 +03:00
parent 8cbc6096dc
commit c04b69fcb7

View file

@ -94,7 +94,7 @@ class HTTPClient:
_last_ping: float
_latency: float
def __new__(cls, **kwargs) -> Awaitable[HTTPClient]:
def __new__(cls, **kwargs: Any) -> Awaitable[HTTPClient]:
# Basically async def __init__
return cls.__async_init(**kwargs)
@ -182,9 +182,7 @@ class HTTPClient:
remaining = self._rates.remaining
return remaining is not None and remaining < 2
@property
def latency(self) -> Awaitable[float]:
async def inner() -> float:
async def latency(self) -> float:
last_ping = self._last_ping
# If there was no ping or the last ping was more than 5 seconds ago.
@ -197,8 +195,6 @@ class HTTPClient:
return self._latency
return inner()
async def request(
self, method: Literal["GET", "POST", "PUT", "DELETE", "PATCH"], path: str, /, **kwargs: Any
):