Skip to content

Commit

Permalink
Update wumpy-rest README
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluenix2 committed Aug 1, 2022
1 parent 37fff54 commit 39d6e14
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions library/wumpy-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TOKEN = 'ABC123.XYZ789'


async def main():
async with APIClient(headers={'Authentication': f'Bot {TOKEN}'}) as api:
async with APIClient(TOKEN) as api:
print(await api.fetch_my_user())


Expand All @@ -27,10 +27,13 @@ made up of multiple route classes. You can create your own class with the
routes you use:

```python
from wumpy.rest import ApplicationCommandRequester, InteractionRequester
from wumpy.rest import (
ApplicationCommandRequester, InteractionRequester,
HTTPXRequester
)


class MyAPIClient(ApplicationCommandRequester, InteractionRequester):
class MyAPIClient(ApplicationCommandRequester, InteractionRequester, HTTPXRequester):

__slots__ = () # Save some memory for this class
```
Expand Down Expand Up @@ -64,12 +67,8 @@ from wumpy.rest import APIClient
class NoOpRatelimiter:
"""Ratelimiter implementation that does nothing; a no-op implementation."""

async def __aenter__(self) -> Callable[
[Route], AsyncContextManager[
Callable[[Mapping[str, str]], Awaitable]
]
]:
return self.acquire
async def __aenter__(self):
return self

async def __aexit__(
self,
Expand All @@ -79,11 +78,8 @@ class NoOpRatelimiter:
) -> object:
pass

async def update(self, headers: Mapping[str, str]) -> object:
pass

@asynccontextmanager
async def acquire(self, route: Route) -> AsyncGenerator[
async def __call__(self, route: Route) -> AsyncGenerator[
Callable[[Mapping[str, str]], Coroutine[Any, Any, object]],
None
]:
Expand All @@ -93,12 +89,12 @@ class NoOpRatelimiter:
# then returns).
yield self.update

async def update(self, headers: Mapping[str, str]) -> object:
pass


async def main():
async with APIClient(
NoOpRatelimiter(),
headers={'Authentication': f'Bot {TOKEN}'}
) as api:
async with APIClient(TOKEN, ratelimiter=NoOpRatelimiter()) as api:
print(await api.fetch_my_user())


Expand Down

0 comments on commit 39d6e14

Please sign in to comment.