from typing import Any, Callable, Dict, MutableMapping, Optional, Tuple, List

from rest_framework.request import Request

class BaseThrottle(object):
    def allow_request(self, request: Request, view) -> bool: ...
    def get_ident(self, request: Request) -> str: ...
    def wait(self) -> Optional[int]: ...

class SimpleRateThrottle(BaseThrottle):
    num_requests: int
    duration: int
    history: List[object]
    rate: Optional[str]
    now: float

    cache: MutableMapping[str, Any] = ...
    timer: Callable[..., float] = ...
    scope: Optional[str] = ...
    cache_format: str = ...
    THROTTLE_RATES: Dict[str, Optional[str]] = ...
    def get_cache_key(self, request: Request, view) -> Optional[str]: ...
    def get_rate(self) -> Optional[str]: ...
    def parse_rate(self, rate) -> Tuple[Optional[int], Optional[int]]: ...
    def throttle_success(self) -> bool: ...
    def throttle_failure(self) -> bool: ...

class AnonRateThrottle(SimpleRateThrottle): ...
class UserRateThrottle(SimpleRateThrottle): ...

class ScopedRateThrottle(SimpleRateThrottle):
    scope_attr: str = ...
