From 29dfc6c5a46f5ff431a4bcafbbec0e72a4b0827e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 5 Apr 2026 07:05:20 +0800 Subject: [PATCH] Fix pycodestyle styling issues --- src/accounting/base_account/commands.py | 8 ++--- src/accounting/base_account/views.py | 3 +- .../journal_entry/utils/description_editor.py | 6 ++-- tests/test_account.py | 32 +++++++++---------- tests/test_site/lib.py | 7 ++-- tests/test_utils.py | 3 +- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/accounting/base_account/commands.py b/src/accounting/base_account/commands.py index 28939f7..234e7a2 100644 --- a/src/accounting/base_account/commands.py +++ b/src/accounting/base_account/commands.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/25 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,9 +34,9 @@ def init_base_accounts_command() -> None: with open(data_dir / "base_accounts.csv") as fp: data: list[dict[str, str]] = [x for x in csv.DictReader(fp)] - account_data: list[dict[str, str]] = [{"code": x["code"], - "title_l10n": title_case(x["title"])} - for x in data] + account_data: list[dict[str, str]] = \ + [{"code": x["code"], "title_l10n": title_case(x["title"])} + for x in data] locales: list[str] = [x[5:] for x in data[0] if x.startswith("l10n-")] l10n_data: list[dict[str, str]] = [{"account_code": x["code"], "locale": y, diff --git a/src/accounting/base_account/views.py b/src/accounting/base_account/views.py index fc43f9a..a177368 100644 --- a/src/accounting/base_account/views.py +++ b/src/accounting/base_account/views.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/1/26 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -50,4 +50,3 @@ def show_account_detail(account: BaseAccount) -> str: :return: The detail. """ return render_template("accounting/base-account/detail.html", obj=account) - diff --git a/src/accounting/journal_entry/utils/description_editor.py b/src/accounting/journal_entry/utils/description_editor.py index 5a79ad6..f894893 100644 --- a/src/accounting/journal_entry/utils/description_editor.py +++ b/src/accounting/journal_entry/utils/description_editor.py @@ -1,7 +1,7 @@ # The Mia! Accounting Project. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/2/27 -# Copyright (c) 2023 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -317,7 +317,7 @@ class DescriptionEditor: def get_condition(code0: str) -> sa.BinaryExpression: m: re.Match = re.match(r"^(\d{4})-(\d{3})$", code0) - assert m is not None,\ + assert m is not None, \ f"Malformed account code \"{code0}\" for regular transactions." return sa.and_(Account.base_code == m.group(1), Account.no == int(m.group(2))) @@ -328,7 +328,7 @@ class DescriptionEditor: = {x.code: x for x in Account.query.filter(sa.or_(*conditions)).all()} for code in codes: - assert code in accounts,\ + assert code in accounts, \ f"Unknown account \"{code}\" for regular transactions." return accounts diff --git a/tests/test_account.py b/tests/test_account.py index e17048e..2ecfc6d 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -334,10 +334,10 @@ class AccountTestCase(unittest.TestCase): self.assertEqual(response.headers["Location"], create_uri) # Success, with spaces to be stripped - response = self.__client.post(store_uri, - data={"csrf_token": self.__csrf_token, - "base_code": f" {STOCK.base_code} ", - "title": f" {STOCK.title} "}) + response = self.__client.post( + store_uri, data={"csrf_token": self.__csrf_token, + "base_code": f" {STOCK.base_code} ", + "title": f" {STOCK.title} "}) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], detail_uri) @@ -574,10 +574,10 @@ class AccountTestCase(unittest.TestCase): set_locale(self.__app, self.__client, self.__csrf_token, "zh_Hant") - response = self.__client.post(update_uri, - data={"csrf_token": self.__csrf_token, - "base_code": CASH.base_code, - "title": f"{CASH.title}-zh_Hant-2"}) + response = self.__client.post( + update_uri, data={"csrf_token": self.__csrf_token, + "base_code": CASH.base_code, + "title": f"{CASH.title}-zh_Hant-2"}) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], detail_uri) @@ -656,10 +656,10 @@ class AccountTestCase(unittest.TestCase): response: httpx.Response for i in range(2, 6): - response = self.__client.post(f"{PREFIX}/store", - data={"csrf_token": self.__csrf_token, - "base_code": "1111", - "title": "Title"}) + response = self.__client.post( + f"{PREFIX}/store", data={"csrf_token": self.__csrf_token, + "base_code": "1111", + "title": "Title"}) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], f"{PREFIX}/1111-00{i}") @@ -707,10 +707,10 @@ class AccountTestCase(unittest.TestCase): response: httpx.Response for i in range(2, 6): - response = self.__client.post(f"{PREFIX}/store", - data={"csrf_token": self.__csrf_token, - "base_code": "1111", - "title": "Title"}) + response = self.__client.post( + f"{PREFIX}/store", data={"csrf_token": self.__csrf_token, + "base_code": "1111", + "title": "Title"}) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], f"{PREFIX}/1111-00{i}") diff --git a/tests/test_site/lib.py b/tests/test_site/lib.py index 821132a..305c315 100644 --- a/tests/test_site/lib.py +++ b/tests/test_site/lib.py @@ -1,7 +1,7 @@ # The Mia! Accounting Demonstration Website. # Author: imacat@mail.imacat.idv.tw (imacat), 2023/4/13 -# Copyright (c) 2023-2024 imacat. +# Copyright (c) 2023-2026 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -259,7 +259,7 @@ class BaseTestData(ABC): :param credit: The credit account code. :return: The debit line item and credit line item. """ - return JournalEntryLineItemData(debit, description, amount),\ + return JournalEntryLineItemData(debit, description, amount), \ JournalEntryLineItemData(credit, description, amount) def _add_journal_entry(self, journal_entry_data: JournalEntryData) -> None: @@ -272,7 +272,8 @@ class BaseTestData(ABC): existing_j_id: set[int] = {x["id"] for x in self.__journal_entries} existing_l_id: set[int] = {x["id"] for x in self.__line_items} journal_entry_data.id = self.__new_id(existing_j_id) - date: dt.date = get_today() - dt.timedelta(days=journal_entry_data.days) + date: dt.date = get_today() - \ + dt.timedelta(days=journal_entry_data.days) self.__journal_entries.append( {"id": journal_entry_data.id, "date": date, diff --git a/tests/test_utils.py b/tests/test_utils.py index 76b2715..cdab678 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -146,7 +146,8 @@ class NextUriTestCase(unittest.TestCase): # A foreign URI next_uri = "https://example.com" - response = client.get(f"/test-invalid-next?next={quote_plus(next_uri)}") + response = client.get( + f"/test-invalid-next?next={quote_plus(next_uri)}") self.assertEqual(response.status_code, 200) response = client.post("/test-invalid-next", data={"csrf_token": csrf_token,