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")
@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):

View File

@ -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)

View File

@ -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.

View File

@ -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

View File

@ -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])