Skip to content

Commit

Permalink
style(pre-commit): auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 3, 2024
1 parent d61d0ab commit 6a2aefe
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions discord/rate_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
from contextlib import asynccontextmanager
from typing import AsyncIterator, Literal, Protocol, cast

from .utils import MISSING

from .errors import DiscordException
from .utils import MISSING


class RateLimitException(DiscordException):
Expand Down Expand Up @@ -63,10 +62,7 @@ class GlobalRateLimit:
"""

def __init__(
self,
concurrency: int,
per: float | int,
remaining: int = MISSING
self, concurrency: int, per: float | int, remaining: int = MISSING
) -> None:
self.concurrency: int = concurrency
self.per: float | int = per
Expand All @@ -78,7 +74,9 @@ def __init__(
self.reset_at: int | float | None = None

if remaining is not MISSING:
raise ValueError("Given rate limit remaining value is larger than concurrency limit")
raise ValueError(
"Given rate limit remaining value is larger than concurrency limit"
)

async def __aenter__(self) -> GlobalRateLimit:
if not self.loop:
Expand Down Expand Up @@ -309,17 +307,17 @@ def _reset(self) -> None:
class BucketStorageProtocol(Protocol):
"""A customizable, optionally replacable storage medium for buckets.
Attributes
----------
ready: :class:`bool`
Whether the BucketStorage is ready.
Parameters
----------
concurrency: :class:`int`
The concurrency to reset every `per` seconds.
per: :class:`int` | :class:`float`
Number of seconds to wait until resetting `concurrency`.
Attributes
----------
ready: :class:`bool`
Whether the BucketStorage is ready.
"""

per: int
Expand Down Expand Up @@ -408,6 +406,7 @@ async def pop_temp_bucket(self, id: str) -> None:
This bucket's identifier.
"""


class BucketStorage(BucketStorageProtocol):
def __init__(self, per: int = 1, concurrency: int = 50) -> None:
self._buckets: dict[str, Bucket] = {}
Expand Down

0 comments on commit 6a2aefe

Please sign in to comment.