@@ -52,7 +52,6 @@ async def _json_or_text(
5252class HTTPClient :
5353 """Represents an HTTP client sending HTTP requests to the Top.gg API.
5454
55- .. _event loop: https://docs.python.org/3/library/asyncio-eventloops.html
5655 .. _aiohttp session: https://aiohttp.readthedocs.io/en/stable/client_reference.html#client-session
5756
5857 Args:
@@ -62,17 +61,17 @@ class HTTPClient:
6261 Keyword Arguments:
6362 session: `aiohttp session`_
6463 The `aiohttp session`_ used for requests to the API.
65- loop: `event loop`_
66- An `event loop`_ used for asynchronous operations .
64+ **kwargs:
65+ Arbitrary kwargs to be passed to :class:`aiohttp.ClientSession` .
6766 """
6867
69- def __init__ (self , token : str , ** kwargs : Any ) -> None :
68+ def __init__ (
69+ self , token : str , * , session : aiohttp .ClientSession = None , ** kwargs : Any
70+ ) -> None :
7071 self .BASE = "https://top.gg/api"
7172 self .token = token
72- self .loop = kwargs .get ("loop" ) or asyncio .get_event_loop ()
73- session = kwargs .get ("session" )
7473 self ._own_session = session is None
75- self .session = session or aiohttp .ClientSession (loop = self . loop )
74+ self .session = session or aiohttp .ClientSession (** kwargs )
7675 self .global_rate_limiter = AsyncRateLimiter (
7776 max_calls = 99 , period = 1 , callback = _rate_limit_handler
7877 )
@@ -140,7 +139,7 @@ async def request(self, method: str, endpoint: str, **kwargs: Any) -> dict:
140139 # if is_global:
141140 # self._global_over.clear()
142141
143- await asyncio .sleep (retry_after , loop = self . loop )
142+ await asyncio .sleep (retry_after )
144143 _LOGGER .debug ("Done sleeping for the ratelimit. Retrying..." )
145144
146145 # release the global lock now that the
0 commit comments