Add ratelimit stubs (#13909)

This commit is contained in:
Tatsh
2025-04-30 18:50:53 -04:00
committed by GitHub
parent dd4ef75460
commit eec809d049
5 changed files with 29 additions and 0 deletions
@@ -0,0 +1,3 @@
# This file lacks __all__ and "now" is only used to set the default value of
# RateLimitDecorator.__init__()'s clock parameter
ratelimit.decorators.now
+2
View File
@@ -0,0 +1,2 @@
version = "2.2.*"
upstream_repository = "https://github.com/tomasbasham/ratelimit"
+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: ...