mirror of https://github.com/zulip/zulip.git
rate_limiter: Fix misplaced type annotation and cleanup code.
You don't put type annotations on return values.
This commit is contained in:
parent
3a0e7c217f
commit
c1a680e2a9
|
@ -21,7 +21,6 @@ tools/deprecated/
|
|||
zproject/
|
||||
zerver/lib/actions.py
|
||||
zerver/lib/bugdown/fenced_code.py
|
||||
zerver/lib/rate_limiter.py
|
||||
zerver/lib/statistics.py
|
||||
zerver/middleware.py
|
||||
zerver/migrations/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from typing import Any, Tuple
|
||||
from typing import Any, Iterator, Tuple
|
||||
|
||||
from django.conf import settings
|
||||
from zerver.lib.redis_utils import get_redis_client
|
||||
|
@ -18,9 +18,13 @@ import logging
|
|||
client = get_redis_client()
|
||||
rules = settings.RATE_LIMITING_RULES
|
||||
def _rules_for_user(user):
|
||||
# type: (UserProfile) -> Any
|
||||
# type: (UserProfile) -> List[Tuple[int, int]]
|
||||
if user.rate_limits != "":
|
||||
return [tuple(int(l) for l in limit.split(':')) for limit in user.rate_limits.split(',')] # type: List[Tuple[int, int]]
|
||||
result = [] # type: List[Tuple[int, int]]
|
||||
for limit in user.rate_limits.split(','):
|
||||
(seconds, requests) = limit.split(':', 2)
|
||||
result.append((int(seconds), int(requests)))
|
||||
return result
|
||||
return rules
|
||||
|
||||
def redis_key(user, domain):
|
||||
|
|
Loading…
Reference in New Issue