From c67fcf0e458ebf087ab17691bfa3af3e5838aee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Mon, 1 Apr 2024 19:53:30 +0200 Subject: [PATCH] chore: adhere to ruff's `A` dont use pythjons builts in functions name as variable --- lnbits/commands.py | 14 +++++++------- lnbits/db.py | 8 ++++---- pyproject.toml | 3 ++- tests/core/views/test_node_api.py | 12 ++++++------ tools/i18n-check.py | 7 ++++--- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lnbits/commands.py b/lnbits/commands.py index 0b7d6edff..af71c586c 100644 --- a/lnbits/commands.py +++ b/lnbits/commands.py @@ -215,10 +215,10 @@ async def database_delete_wallet_payment(wallet: str, checking_id: str): @db.command("mark-payment-pending") @click.option("-c", "--checking-id", required=True, help="Payment checking Id.") @coro -async def database_revert_payment(checking_id: str, pending: Optional[bool] = True): +async def database_revert_payment(checking_id: str, pending: bool = True): """Mark wallet as deleted""" async with core_db.connect() as conn: - await update_payment_status(pending=True, checking_id=checking_id, conn=conn) + await update_payment_status(pending=pending, checking_id=checking_id, conn=conn) @db.command("cleanup-accounts") @@ -333,7 +333,7 @@ async def extensions_list(): @extensions.command("update") @click.argument("extension", required=False) -@click.option("-a", "--all", is_flag=True, help="Update all extensions.") +@click.option("-a", "--all-extensions", is_flag=True, help="Update all extensions.") @click.option( "-i", "--repo-index", help="Select the index of the repository to be used." ) @@ -360,7 +360,7 @@ async def extensions_list(): @coro async def extensions_update( extension: Optional[str] = None, - all: Optional[bool] = False, + all_extensions: Optional[bool] = False, repo_index: Optional[str] = None, source_repo: Optional[str] = None, url: Optional[str] = None, @@ -370,11 +370,11 @@ async def extensions_update( Update extension to the latest version. If an extension is not present it will be instaled. """ - if not extension and not all: + if not extension and not all_extensions: click.echo("Extension ID is required.") - click.echo("Or specify the '--all' flag to update all extensions") + click.echo("Or specify the '--all-extensions' flag to update all extensions") return - if extension and all: + if extension and all_extensions: click.echo("Only one of extension ID or the '--all' flag must be specified") return if url and not _is_url(url): diff --git a/lnbits/db.py b/lnbits/db.py index a6fdde7e2..652d7f4be 100644 --- a/lnbits/db.py +++ b/lnbits/db.py @@ -478,8 +478,8 @@ class Filters(BaseModel, Generic[TFilterModel]): if not where_stmts: where_stmts = [] if self.filters: - for filter in self.filters: - where_stmts.append(filter.statement) + for page_filter in self.filters: + where_stmts.append(page_filter.statement) if self.search and self.model: if DB_TYPE == POSTGRES: where_stmts.append( @@ -502,8 +502,8 @@ class Filters(BaseModel, Generic[TFilterModel]): if not values: values = [] if self.filters: - for filter in self.filters: - values.extend(filter.values) + for page_filter in self.filters: + values.extend(page_filter.values) if self.search and self.model: values.append(f"%{self.search}%") return tuple(values) diff --git a/pyproject.toml b/pyproject.toml index 4e856c179..111614d03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -163,7 +163,8 @@ extend-exclude = [ # E - pycodestyle errors # W - pycodestyle warnings # I - isort -select = ["F", "E", "W", "I"] +# A - flake8-builtins +select = ["F", "E", "W", "I", "A"] ignore = [] # Allow autofix for all enabled rules (when `--fix`) is provided. diff --git a/tests/core/views/test_node_api.py b/tests/core/views/test_node_api.py index 37da080d0..1799c5ec0 100644 --- a/tests/core/views/test_node_api.py +++ b/tests/core/views/test_node_api.py @@ -60,7 +60,7 @@ async def test_public_node_info(public_node_client): @pytest.mark.asyncio -async def test_node_info(node_client, from_super_user): +async def test_node_info(node_client): response = await node_client.get("/node/api/v1/info") assert response.status_code == 200 @@ -147,23 +147,23 @@ async def test_channel_management(node_client): @pytest.mark.asyncio async def test_peer_management(node_client): connect_uri = get_unconnected_node_uri() - id = connect_uri.split("@")[0] + peer_id = connect_uri.split("@")[0] response = await node_client.post("/node/api/v1/peers", json={"uri": connect_uri}) assert response.status_code == 200 response = await node_client.get("/node/api/v1/peers") assert response.status_code == 200 - assert any(peer["id"] == id for peer in response.json()) + assert any(peer["id"] == peer_id for peer in response.json()) - response = await node_client.delete(f"/node/api/v1/peers/{id}") + response = await node_client.delete(f"/node/api/v1/peers/{peer_id}") assert response.status_code == 200 await asyncio.sleep(0.1) response = await node_client.get("/node/api/v1/peers") assert response.status_code == 200 - assert not any(peer["id"] == id for peer in response.json()) + assert not any(peer["id"] == peer_id for peer in response.json()) - response = await node_client.delete(f"/node/api/v1/peers/{id}") + response = await node_client.delete(f"/node/api/v1/peers/{peer_id}") assert response.status_code == 400 diff --git a/tools/i18n-check.py b/tools/i18n-check.py index 82032facd..1c92dc800 100644 --- a/tools/i18n-check.py +++ b/tools/i18n-check.py @@ -6,10 +6,10 @@ def get_translation_ids_from_source(): # find all HTML files in selected directories files = [] for start in ["lnbits/core/templates", "lnbits/templates", "lnbits/static/js"]: - for dir, _, filenames in os.walk(start): + for check_dir, _, filenames in os.walk(start): for filename in filenames: if filename.endswith(".html") or filename.endswith(".js"): - fn = os.path.join(dir, filename) + fn = os.path.join(check_dir, filename) files.append(fn) # find all $t('...') and $t("...") calls in HTML files # and extract the string inside the quotes @@ -56,7 +56,8 @@ if len(extra) > 0: print(f" {i}") languages = [] -for dir, _, filenames in os.walk("lnbits/static/i18n"): + +for *_, filenames in os.walk("lnbits/static/i18n"): for filename in filenames: if filename.endswith(".js") and filename not in ["i18n.js", "en.js"]: languages.append(filename.split(".")[0])