From 807d8a1f1e90f6eebbbeb47cc7ed69bc59d36f04 Mon Sep 17 00:00:00 2001 From: Ali-Akber Saifee Date: Sun, 5 Jan 2025 12:22:09 -0800 Subject: [PATCH] Simplify exempt decorator using functools.partial --- flask_limiter/extension.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/flask_limiter/extension.py b/flask_limiter/extension.py index 4f0f238..869014b 100644 --- a/flask_limiter/extension.py +++ b/flask_limiter/extension.py @@ -6,6 +6,7 @@ import dataclasses import datetime +import functools import itertools import logging import time @@ -39,7 +40,6 @@ Sequence, Set, Tuple, - TypeVar, Union, cast, ) @@ -730,13 +730,8 @@ def route(...): elif obj: self.limit_manager.add_route_exemption(get_qualified_name(obj), flags) else: - _R = TypeVar("_R") - _WO = TypeVar("_WO", Callable[..., _R], flask.Blueprint) + return functools.partial(self.exempt, flags=flags) - def wrapper(obj: _WO) -> _WO: - return self.exempt(obj, flags=flags) - - return wrapper return obj def request_filter(self, fn: Callable[[], bool]) -> Callable[[], bool]: