Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Reuben Thomas-Davis <[email protected]>
  • Loading branch information
laurentS and Rested committed Aug 21, 2023
1 parent 90f2ed3 commit 93046a0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions slowapi/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
self.methods = methods
self.error_message = error_message
self.exempt_when = exempt_when
self._exempt_when_takes_request = len(inspect.signature(self.exempt_when).parameters) == 1
self.cost = cost
self.override_defaults = override_defaults

Expand All @@ -43,9 +44,7 @@ def is_exempt(self, request: Optional[Request] = None) -> bool:
"""
if self.exempt_when is None:
return False
params = inspect.signature(self.exempt_when).parameters
param_len = len(params)
if param_len == 1 and request:
if self._exempt_when_takes_request and request:
return self.exempt_when(request)
return self.exempt_when()

Expand Down

0 comments on commit 93046a0

Please sign in to comment.