More flake8

This commit is contained in:
awiebe 2023-08-25 17:26:54 -07:00 committed by GitHub
parent 2e90c5acd3
commit 2fa181754e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,7 @@ class SimpleRateThrottle(BaseThrottle):
cache_format = 'throttle_%(scope)s_%(ident)s' cache_format = 'throttle_%(scope)s_%(ident)s'
scope = None scope = None
THROTTLE_RATES = api_settings.DEFAULT_THROTTLE_RATES THROTTLE_RATES = api_settings.DEFAULT_THROTTLE_RATES
_RATE_DENOMINATOR_REGEX= re.compile("^(\d*)(\D+)$") _RATE_DENOMINATOR_REGEX = re.compile(r"^(\d*)(\D+)$")
def __init__(self): def __init__(self):
if not getattr(self, 'rate', None): if not getattr(self, 'rate', None):
@ -113,8 +113,8 @@ class SimpleRateThrottle(BaseThrottle):
m = re.search(self._RATE_DENOMINATOR_REGEX, denominator) m = re.search(self._RATE_DENOMINATOR_REGEX, denominator)
dg = m.groups() dg = m.groups()
dn= int(m[0]) if len(m[0]) > 0 else 1 dn= int(dg[0]) if len(dg[0]) > 0 else 1
du = m[1][0] du = dg[1][0]
duration = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400}[du] duration = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400}[du]
duration *= dn duration *= dn