chore: adhere to ruff's A

dont use pythjons builts in functions name as variable
This commit is contained in:
dni ⚡ 2024-04-01 19:53:30 +02:00 committed by Pavol Rusnak
parent 073b117528
commit c67fcf0e45
5 changed files with 23 additions and 21 deletions

View File

@ -215,10 +215,10 @@ async def database_delete_wallet_payment(wallet: str, checking_id: str):
@db.command("mark-payment-pending") @db.command("mark-payment-pending")
@click.option("-c", "--checking-id", required=True, help="Payment checking Id.") @click.option("-c", "--checking-id", required=True, help="Payment checking Id.")
@coro @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""" """Mark wallet as deleted"""
async with core_db.connect() as conn: 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") @db.command("cleanup-accounts")
@ -333,7 +333,7 @@ async def extensions_list():
@extensions.command("update") @extensions.command("update")
@click.argument("extension", required=False) @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( @click.option(
"-i", "--repo-index", help="Select the index of the repository to be used." "-i", "--repo-index", help="Select the index of the repository to be used."
) )
@ -360,7 +360,7 @@ async def extensions_list():
@coro @coro
async def extensions_update( async def extensions_update(
extension: Optional[str] = None, extension: Optional[str] = None,
all: Optional[bool] = False, all_extensions: Optional[bool] = False,
repo_index: Optional[str] = None, repo_index: Optional[str] = None,
source_repo: Optional[str] = None, source_repo: Optional[str] = None,
url: Optional[str] = None, url: Optional[str] = None,
@ -370,11 +370,11 @@ async def extensions_update(
Update extension to the latest version. Update extension to the latest version.
If an extension is not present it will be instaled. 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("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 return
if extension and all: if extension and all_extensions:
click.echo("Only one of extension ID or the '--all' flag must be specified") click.echo("Only one of extension ID or the '--all' flag must be specified")
return return
if url and not _is_url(url): if url and not _is_url(url):

View File

@ -478,8 +478,8 @@ class Filters(BaseModel, Generic[TFilterModel]):
if not where_stmts: if not where_stmts:
where_stmts = [] where_stmts = []
if self.filters: if self.filters:
for filter in self.filters: for page_filter in self.filters:
where_stmts.append(filter.statement) where_stmts.append(page_filter.statement)
if self.search and self.model: if self.search and self.model:
if DB_TYPE == POSTGRES: if DB_TYPE == POSTGRES:
where_stmts.append( where_stmts.append(
@ -502,8 +502,8 @@ class Filters(BaseModel, Generic[TFilterModel]):
if not values: if not values:
values = [] values = []
if self.filters: if self.filters:
for filter in self.filters: for page_filter in self.filters:
values.extend(filter.values) values.extend(page_filter.values)
if self.search and self.model: if self.search and self.model:
values.append(f"%{self.search}%") values.append(f"%{self.search}%")
return tuple(values) return tuple(values)

View File

@ -163,7 +163,8 @@ extend-exclude = [
# E - pycodestyle errors # E - pycodestyle errors
# W - pycodestyle warnings # W - pycodestyle warnings
# I - isort # I - isort
select = ["F", "E", "W", "I"] # A - flake8-builtins
select = ["F", "E", "W", "I", "A"]
ignore = [] ignore = []
# Allow autofix for all enabled rules (when `--fix`) is provided. # Allow autofix for all enabled rules (when `--fix`) is provided.

View File

@ -60,7 +60,7 @@ async def test_public_node_info(public_node_client):
@pytest.mark.asyncio @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") response = await node_client.get("/node/api/v1/info")
assert response.status_code == 200 assert response.status_code == 200
@ -147,23 +147,23 @@ async def test_channel_management(node_client):
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_peer_management(node_client): async def test_peer_management(node_client):
connect_uri = get_unconnected_node_uri() 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}) response = await node_client.post("/node/api/v1/peers", json={"uri": connect_uri})
assert response.status_code == 200 assert response.status_code == 200
response = await node_client.get("/node/api/v1/peers") response = await node_client.get("/node/api/v1/peers")
assert response.status_code == 200 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 assert response.status_code == 200
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
response = await node_client.get("/node/api/v1/peers") response = await node_client.get("/node/api/v1/peers")
assert response.status_code == 200 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 assert response.status_code == 400

View File

@ -6,10 +6,10 @@ def get_translation_ids_from_source():
# find all HTML files in selected directories # find all HTML files in selected directories
files = [] files = []
for start in ["lnbits/core/templates", "lnbits/templates", "lnbits/static/js"]: 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: for filename in filenames:
if filename.endswith(".html") or filename.endswith(".js"): if filename.endswith(".html") or filename.endswith(".js"):
fn = os.path.join(dir, filename) fn = os.path.join(check_dir, filename)
files.append(fn) files.append(fn)
# find all $t('...') and $t("...") calls in HTML files # find all $t('...') and $t("...") calls in HTML files
# and extract the string inside the quotes # and extract the string inside the quotes
@ -56,7 +56,8 @@ if len(extra) > 0:
print(f" {i}") print(f" {i}")
languages = [] languages = []
for dir, _, filenames in os.walk("lnbits/static/i18n"):
for *_, filenames in os.walk("lnbits/static/i18n"):
for filename in filenames: for filename in filenames:
if filename.endswith(".js") and filename not in ["i18n.js", "en.js"]: if filename.endswith(".js") and filename not in ["i18n.js", "en.js"]:
languages.append(filename.split(".")[0]) languages.append(filename.split(".")[0])