Add ratelimit stubs (#13909)

This commit is contained in:
Tatsh authored and GitHub committed 2025-05-01 00:50:53 +02:00
1 parent dd4ef75460
commit eec809d049
5 files changed
+29

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
from ratelimit.decorators import RateLimitDecorator, sleep_and_retry
from ratelimit.exception import RateLimitException
limits = RateLimitDecorator
rate_limited = RateLimitDecorator
__all__ = ["RateLimitException", "limits", "rate_limited", "sleep_and_retry"]
+14
View File
@@ -0,0 +1,14 @@
from collections.abc import Callable
from typing import TypeVar
from typing_extensions import ParamSpec
_P = ParamSpec("_P")
_T = TypeVar("_T")
class RateLimitDecorator:
def __init__(
self, calls: int = 15, period: float = 900, clock: Callable[[], float] = ..., raise_on_limit: bool = True
) -> None: ...
def __call__(self, func: Callable[_P, _T]) -> Callable[_P, _T]: ...
def sleep_and_retry(func: Callable[_P, _T]) -> Callable[_P, _T]: ...
+3
View File
@@ -0,0 +1,3 @@
class RateLimitException(Exception):
period_remaining: float
def __init__(self, message: str, period_remaining: float) -> None: ...