@@ -15,7 +15,7 @@ TOKEN = 'ABC123.XYZ789'
1515
1616
1717async def main ():
18- async with APIClient(headers = { ' Authentication ' : f ' Bot { TOKEN } ' } ) as api:
18+ async with APIClient(TOKEN ) as api:
1919 print (await api.fetch_my_user())
2020
2121
@@ -27,10 +27,13 @@ made up of multiple route classes. You can create your own class with the
2727routes you use:
2828
2929``` python
30- from wumpy.rest import ApplicationCommandRequester, InteractionRequester
30+ from wumpy.rest import (
31+ ApplicationCommandRequester, InteractionRequester,
32+ HTTPXRequester
33+ )
3134
3235
33- class MyAPIClient (ApplicationCommandRequester , InteractionRequester ):
36+ class MyAPIClient (ApplicationCommandRequester , InteractionRequester , HTTPXRequester ):
3437
3538 __slots__ = () # Save some memory for this class
3639```
@@ -64,12 +67,8 @@ from wumpy.rest import APIClient
6467class NoOpRatelimiter :
6568 """ Ratelimiter implementation that does nothing; a no-op implementation."""
6669
67- async def __aenter__ (self ) -> Callable[
68- [Route], AsyncContextManager[
69- Callable[[Mapping[str , str ]], Awaitable]
70- ]
71- ]:
72- return self .acquire
70+ async def __aenter__ (self ):
71+ return self
7372
7473 async def __aexit__ (
7574 self ,
@@ -79,11 +78,8 @@ class NoOpRatelimiter:
7978 ) -> object :
8079 pass
8180
82- async def update (self , headers : Mapping[str , str ]) -> object :
83- pass
84-
8581 @asynccontextmanager
86- async def acquire (self , route : Route) -> AsyncGenerator[
82+ async def __call__ (self , route : Route) -> AsyncGenerator[
8783 Callable[[Mapping[str , str ]], Coroutine[Any, Any, object ]],
8884 None
8985 ]:
@@ -93,12 +89,12 @@ class NoOpRatelimiter:
9389 # then returns).
9490 yield self .update
9591
92+ async def update (self , headers : Mapping[str , str ]) -> object :
93+ pass
94+
9695
9796async def main ():
98- async with APIClient(
99- NoOpRatelimiter(),
100- headers = {' Authentication' : f ' Bot { TOKEN } ' }
101- ) as api:
97+ async with APIClient(TOKEN , ratelimiter = NoOpRatelimiter()) as api:
10298 print (await api.fetch_my_user())
10399
104100
0 commit comments