Skip to content

Commit 39d6e14

Browse files
committed
Update wumpy-rest README
1 parent 37fff54 commit 39d6e14

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

library/wumpy-rest/README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ TOKEN = 'ABC123.XYZ789'
1515

1616

1717
async 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
2727
routes 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
6467
class 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

9796
async 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

Comments
 (0)