From aa3e108d0a2e125289a0dd9ce8af240d00ab52cd Mon Sep 17 00:00:00 2001 From: thentgesMindee Date: Thu, 3 Nov 2022 17:39:33 +0100 Subject: [PATCH] fix: :label: update type annotations --- slowapi/extension.py | 2 +- slowapi/middleware.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/slowapi/extension.py b/slowapi/extension.py index d42df2a..059ba00 100644 --- a/slowapi/extension.py +++ b/slowapi/extension.py @@ -540,7 +540,7 @@ class Limiter: def _check_request_limit( self, request: Request, - endpoint_func: Callable[..., Any], + endpoint_func: Optional[Callable[..., Any]], in_middleware: bool = True, ) -> None: """ diff --git a/slowapi/middleware.py b/slowapi/middleware.py index 0e5cdb7..5755a46 100644 --- a/slowapi/middleware.py +++ b/slowapi/middleware.py @@ -1,5 +1,5 @@ import inspect -from typing import Callable, Coroutine, Iterable, Optional, Tuple, Type, Union +from typing import Callable, Iterable, Optional, Tuple, Type from starlette.applications import Starlette from starlette.datastructures import MutableHeaders @@ -26,13 +26,13 @@ def _find_route_handler( return handler -def _get_route_name(handler: Type[Callable]): +def _get_route_name(handler: Callable): return "%s.%s" % (handler.__module__, handler.__name__) def _check_limits( limiter: Limiter, request: Request, handler: Optional[Callable], app: Starlette -) -> Tuple[Optional[Union[Callable, Coroutine]], bool, Optional[Exception]]: +) -> Tuple[Optional[Callable], bool, Optional[Exception]]: """ Utils to check (if needed) current requests limit. It returns a tuple of size 3: @@ -74,7 +74,7 @@ def sync_check_limits( if inspect.iscoroutinefunction(exception_handler): exception_handler = _rate_limit_exceeded_handler - return exception_handler(request, exc), _bool + return exception_handler(request, exc), _bool # type: ignore async def async_check_limits(