Revised the code as suggested by PyCharm.
This commit is contained in:
@ -56,10 +56,10 @@ class AccountBackend:
|
||||
"""Returns the user by her log in user name.
|
||||
|
||||
Args:
|
||||
username (str): The log in user name.
|
||||
username: The log in user name.
|
||||
|
||||
Return:
|
||||
User: The user, or None if the user does not eixst.
|
||||
The user, or None if the user does not exist.
|
||||
"""
|
||||
return User.objects.filter(login_id=username).first()
|
||||
|
||||
@ -133,7 +133,9 @@ def _get_host(ip: str) -> Optional[str]:
|
||||
"""
|
||||
try:
|
||||
return socket.gethostbyaddr(ip)[0]
|
||||
except Exception:
|
||||
except socket.herror:
|
||||
return None
|
||||
except socket.gaierror:
|
||||
return None
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@ class UserForm(forms.Form):
|
||||
raise error
|
||||
|
||||
def _validate_passwords_equal(self) -> None:
|
||||
"""Validates whether the two passwords are equa.
|
||||
"""Validates whether the two passwords are equal.
|
||||
|
||||
Raises:
|
||||
forms.ValidationError: When the validation fails.
|
||||
|
@ -20,8 +20,7 @@
|
||||
"""
|
||||
import datetime
|
||||
import re
|
||||
from datetime import date
|
||||
from typing import Optional, List, Any, Union
|
||||
from typing import Optional, List
|
||||
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.template import defaultfilters
|
||||
@ -461,7 +460,7 @@ class Period:
|
||||
self.start = datetime.date(year, month, 1)
|
||||
self.end = self._month_last_day(timezone.localdate())
|
||||
self.description = gettext("Since %s")\
|
||||
% self._month_text(year, month)
|
||||
% self._month_text(year, month)
|
||||
self.prep_desc = self.description
|
||||
return
|
||||
# Until a specific month
|
||||
@ -474,7 +473,7 @@ class Period:
|
||||
self.start = Period.Parser.VERY_START
|
||||
self.end = self._month_last_day(until_month)
|
||||
self.description = gettext("Until %s")\
|
||||
% self._month_text(year, month)
|
||||
% self._month_text(year, month)
|
||||
self.prep_desc = self.description
|
||||
return
|
||||
# A specific year
|
||||
@ -495,7 +494,7 @@ class Period:
|
||||
self.end = datetime.date(year, 12, 31)
|
||||
self.start = Period.Parser.VERY_START
|
||||
self.description = gettext("Until %s")\
|
||||
% self._year_text(year)
|
||||
% self._year_text(year)
|
||||
self.prep_desc = self.description
|
||||
return
|
||||
# All time
|
||||
@ -574,7 +573,7 @@ class Period:
|
||||
int(m.group(3)))
|
||||
self.start = Period.Parser.VERY_START
|
||||
self.description = gettext("Until %s")\
|
||||
% self._date_text(self.end)
|
||||
% self._date_text(self.end)
|
||||
self.prep_desc = self.description
|
||||
return
|
||||
# Wrong period format
|
||||
|
@ -211,4 +211,4 @@ def is_in_section(request: HttpRequest, section_name: str) -> bool:
|
||||
return False
|
||||
view_name = request.resolver_match.view_name
|
||||
return view_name == section_name\
|
||||
or view_name.startswith(section_name + ".")
|
||||
or view_name.startswith(section_name + ".")
|
||||
|
Reference in New Issue
Block a user