mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
Introduce gradual typing with mypy
This commit is contained in:
parent
911de8f347
commit
8c73eed726
5 changed files with 15 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,6 +4,7 @@
|
|||
.coverage
|
||||
.DS_Store
|
||||
.idea
|
||||
.mypy_cache/
|
||||
.project
|
||||
.pydevproject
|
||||
.python-version
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def _query_user_attempts(request, credentials=None):
|
|||
return attempts
|
||||
|
||||
|
||||
def get_cache_key(request_or_obj, credentials=None):
|
||||
def get_cache_key(request_or_obj, credentials=None) -> str:
|
||||
"""
|
||||
Build cache key name from request or AccessAttempt object.
|
||||
|
||||
|
|
@ -132,28 +132,28 @@ def get_user_attempts(request, credentials=None):
|
|||
return attempts
|
||||
|
||||
|
||||
def reset_user_attempts(request, credentials=None):
|
||||
def reset_user_attempts(request, credentials=None) -> int:
|
||||
attempts = _query_user_attempts(request, credentials)
|
||||
count, _ = attempts.delete()
|
||||
|
||||
return count
|
||||
|
||||
|
||||
def ip_in_whitelist(ip):
|
||||
def ip_in_whitelist(ip) -> bool:
|
||||
if not settings.AXES_IP_WHITELIST:
|
||||
return False
|
||||
|
||||
return ip in settings.AXES_IP_WHITELIST
|
||||
|
||||
|
||||
def ip_in_blacklist(ip):
|
||||
def ip_in_blacklist(ip) -> bool:
|
||||
if not settings.AXES_IP_BLACKLIST:
|
||||
return False
|
||||
|
||||
return ip in settings.AXES_IP_BLACKLIST
|
||||
|
||||
|
||||
def is_user_lockable(request, credentials=None):
|
||||
def is_user_lockable(request, credentials=None) -> bool:
|
||||
if request.method != 'POST':
|
||||
return True
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ def is_user_lockable(request, credentials=None):
|
|||
return True
|
||||
|
||||
|
||||
def is_already_locked(request, credentials=None):
|
||||
def is_already_locked(request, credentials=None) -> bool:
|
||||
ip = get_client_ip(request)
|
||||
|
||||
if (
|
||||
|
|
|
|||
6
mypy.ini
Normal file
6
mypy.ini
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[mypy]
|
||||
python_version = 3.5
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-axes.migrations.*]
|
||||
ignore_errors = True
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
-e .
|
||||
coverage==4.5.2
|
||||
mypy==0.670
|
||||
prospector==1.1.6.2
|
||||
sphinx_rtd_theme==0.4.2
|
||||
tox==3.7.0
|
||||
|
|
|
|||
1
tox.ini
1
tox.ini
|
|
@ -30,5 +30,6 @@ commands =
|
|||
coverage run -a manage.py test -v2
|
||||
coverage report
|
||||
prospector
|
||||
mypy axes
|
||||
setenv =
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
|
|
|||
Loading…
Reference in a new issue