Skip to content

Commit

Permalink
Simplify exempt decorator using functools.partial
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Jan 5, 2025
1 parent 2b223b5 commit 807d8a1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions flask_limiter/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import dataclasses
import datetime
import functools
import itertools
import logging
import time
Expand Down Expand Up @@ -39,7 +40,6 @@
Sequence,
Set,
Tuple,
TypeVar,
Union,
cast,
)
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 807d8a1

Please sign in to comment.