From 36f55900c7a870ee0d9b11cb25d58f05d242d193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Thu, 9 Feb 2023 00:02:14 +0800 Subject: [PATCH] Renamed "fh" to "fp" when opening files, following the Python convention. --- src/accounting/base_account/commands.py | 4 ++-- src/accounting/currency/commands.py | 4 ++-- tests/test_base_account.py | 4 ++-- tests/test_currency.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/accounting/base_account/commands.py b/src/accounting/base_account/commands.py index 1621108..bc8cb5e 100644 --- a/src/accounting/base_account/commands.py +++ b/src/accounting/base_account/commands.py @@ -35,8 +35,8 @@ def init_base_accounts_command() -> None: click.echo("Base accounts already exist.") raise click.Abort - with open(data_dir / "base_accounts.csv") as fh: - data: list[dict[str, str]] = [x for x in csv.DictReader(fh)] + 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": x["title"]} for x in data] diff --git a/src/accounting/currency/commands.py b/src/accounting/currency/commands.py index 5c640cf..8e7e7ad 100644 --- a/src/accounting/currency/commands.py +++ b/src/accounting/currency/commands.py @@ -58,8 +58,8 @@ def init_currencies_command(username: str) -> None: """Initializes the currencies.""" existing_codes: set[str] = {x.code for x in Currency.query.all()} - with open(data_dir / "currencies.csv") as fh: - data: list[dict[str, str]] = [x for x in csv.DictReader(fh)] + with open(data_dir / "currencies.csv") as fp: + data: list[dict[str, str]] = [x for x in csv.DictReader(fp)] to_add: list[dict[str, str]] = [x for x in data if x["code"] not in existing_codes] if len(to_add) == 0: diff --git a/tests/test_base_account.py b/tests/test_base_account.py index aaef457..4d808e1 100644 --- a/tests/test_base_account.py +++ b/tests/test_base_account.py @@ -57,13 +57,13 @@ class BaseAccountCommandTestCase(unittest.TestCase): from accounting import data_dir from accounting.models import BaseAccount - with open(data_dir / "base_accounts.csv") as fh: + with open(data_dir / "base_accounts.csv") as fp: data: dict[dict[str, t.Any]] \ = {x["code"]: {"code": x["code"], "title": x["title"], "l10n": {y[5:]: x[y] for y in x if y.startswith("l10n-")}} - for x in csv.DictReader(fh)} + for x in csv.DictReader(fp)} runner: FlaskCliRunner = self.app.test_cli_runner() result: Result = runner.invoke(args="accounting-init-base") diff --git a/tests/test_currency.py b/tests/test_currency.py index bd5710c..f9dcfeb 100644 --- a/tests/test_currency.py +++ b/tests/test_currency.py @@ -88,13 +88,13 @@ class CurrencyCommandTestCase(unittest.TestCase): from accounting import data_dir from accounting.models import Currency - with open(data_dir / "currencies.csv") as fh: + with open(data_dir / "currencies.csv") as fp: data: dict[dict[str, t.Any]] \ = {x["code"]: {"code": x["code"], "name": x["name"], "l10n": {y[5:]: x[y] for y in x if y.startswith("l10n-")}} - for x in csv.DictReader(fh)} + for x in csv.DictReader(fp)} runner: FlaskCliRunner = self.app.test_cli_runner() with self.app.app_context():