Revised the code as suggested by PyCharm.

This commit is contained in:
依瑪貓 2020-08-13 10:17:52 +08:00
parent 1be05c2252
commit e06821194c
8 changed files with 17 additions and 19 deletions

View File

@ -30,9 +30,6 @@
.date-account-line { .date-account-line {
font-size: 0.833em; font-size: 0.833em;
} }
.negative {
color: red;
}
.journal-credit { .journal-credit {
padding-left: 1em; padding-left: 1em;
} }

View File

@ -24,7 +24,7 @@
/** /**
* Returns the regular payment data. * Returns the regular payment data.
* *
* @returns {{debits: [], credits: []}} * @returns {{debit: [], credit: []}}
*/ */
function getRegularPayments() { function getRegularPayments() {
const today = new Date($("#txn-date").get(0).value); const today = new Date($("#txn-date").get(0).value);

View File

@ -142,7 +142,7 @@ function loadSummaryCategoryData() {
*/ */
function startSummaryHelper(summary) { function startSummaryHelper(summary) {
// Replaced common substitution character "*" with "×" // Replaced common substitution character "*" with "×"
summary_content = summary.val(); let summary_content = summary.val();
summary_content = summary_content.replace(/\*(\d+)$/, "×$1"); summary_content = summary_content.replace(/\*(\d+)$/, "×$1");
const type = summary.data("type"); const type = summary.data("type");
const no = summary.data("no"); const no = summary.data("no");
@ -331,7 +331,7 @@ function switchSummaryTab(tab) {
/** /**
* Sets the known general category buttons. * Sets the known general category buttons.
* *
* @param {string} category the general category * @param {string|null} category the general category
*/ */
function setSummaryGeneralCategoryButtons(category) { function setSummaryGeneralCategoryButtons(category) {
$(".btn-summary-general-category").each(function () { $(".btn-summary-general-category").each(function () {
@ -480,7 +480,7 @@ function setSummaryRegularPaymentButtons(category) {
* *
* @param {string} format the category format, either "general", * @param {string} format the category format, either "general",
* "travel", or "bus". * "travel", or "bus".
* @param {string} category the category * @param {string|null} category the category
*/ */
function setSummaryAccount(format, category) { function setSummaryAccount(format, category) {
const recordId = $("#summary-record").get(0).value; const recordId = $("#summary-record").get(0).value;

View File

@ -43,7 +43,7 @@ def accounting_amount(value: Union[str, int]) -> str:
break break
s = m.group(1) + "," + m.group(2) s = m.group(1) + "," + m.group(2)
if value < 0: if value < 0:
s = "(%s)" % (s) s = "(%s)" % s
return s return s

View File

@ -56,10 +56,10 @@ class AccountBackend:
"""Returns the user by her log in user name. """Returns the user by her log in user name.
Args: Args:
username (str): The log in user name. username: The log in user name.
Return: 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() return User.objects.filter(login_id=username).first()
@ -133,7 +133,9 @@ def _get_host(ip: str) -> Optional[str]:
""" """
try: try:
return socket.gethostbyaddr(ip)[0] return socket.gethostbyaddr(ip)[0]
except Exception: except socket.herror:
return None
except socket.gaierror:
return None return None

View File

@ -146,7 +146,7 @@ class UserForm(forms.Form):
raise error raise error
def _validate_passwords_equal(self) -> None: def _validate_passwords_equal(self) -> None:
"""Validates whether the two passwords are equa. """Validates whether the two passwords are equal.
Raises: Raises:
forms.ValidationError: When the validation fails. forms.ValidationError: When the validation fails.

View File

@ -20,8 +20,7 @@
""" """
import datetime import datetime
import re import re
from datetime import date from typing import Optional, List
from typing import Optional, List, Any, Union
from django.core.serializers.json import DjangoJSONEncoder from django.core.serializers.json import DjangoJSONEncoder
from django.template import defaultfilters from django.template import defaultfilters