mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 12:35:49 +08:00
Add ratelimit stubs (#13909)
This commit is contained in:
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
version = "2.2.*"
|
||||
upstream_repository = "https://github.com/tomasbasham/ratelimit"
|
||||
@@ -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"]
|
||||
@@ -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]: ...
|
||||
@@ -0,0 +1,3 @@
|
||||
class RateLimitException(Exception):
|
||||
period_remaining: float
|
||||
def __init__(self, message: str, period_remaining: float) -> None: ...
|
||||
Reference in New Issue
Block a user