From 1a17eba9fb78288aef32a2942013fd024c1b0ca3 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Wed, 22 Jan 2025 16:15:44 +0100 Subject: [PATCH] Bump black to v0.9.2 Apply Black 2025 format Disable COM check as recommended --- .pre-commit-config.yaml | 2 +- pyproject.toml | 4 ++-- silkaj/auth.py | 4 +++- silkaj/blockchain/difficulty.py | 10 +++++----- silkaj/money/history.py | 6 +++--- silkaj/wot/lookup.py | 2 +- silkaj/wot/status.py | 14 +++++++------- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7748456d..1962c00c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: mixed-line-ending - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.5 + rev: v0.9.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/pyproject.toml b/pyproject.toml index 42725166..ab08a269 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,6 @@ ignore_missing_imports = true [tool.ruff] target-version = "py39" lint.select = ["F", "W", "I", "UP", "YTT", "B", "A", "DTZ", "T10", -"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", "PL", -"COM", "C4", "PT", "RET", "SIM", "PTH", "PGH", "PL", "TRY", "RUF"] +"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", +"PL", "C4", "PT", "RET", "SIM", "PTH", "PGH", "PL", "TRY", "RUF"] lint.ignore = ["PLR2004", "PLR0913"] diff --git a/silkaj/auth.py b/silkaj/auth.py index 90f22fff..e394bb06 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -59,8 +59,10 @@ def generate_auth_file(auth_file: Path) -> None: key = auth_method() pubkey_cksum = gen_pubkey_checksum(key.pubkey) if auth_file.is_file(): - message = f"Would you like to erase {auth_file} with an authentication file corresponding \n\ + message = ( + f"Would you like to erase {auth_file} with an authentication file corresponding \n\ to following pubkey `{pubkey_cksum}`?" + ) click.confirm(message, abort=True) key.save_seedhex_file(auth_file) print( diff --git a/silkaj/blockchain/difficulty.py b/silkaj/blockchain/difficulty.py index a0faaa95..6576c6ca 100644 --- a/silkaj/blockchain/difficulty.py +++ b/silkaj/blockchain/difficulty.py @@ -60,11 +60,11 @@ def display_diffi(current: WSConnection, diffi: dict) -> None: table = tui.Table(style="columns").set_cols_dtype(["t", "t", "t", "i"]) table.fill_from_dict_list(sorted_diffi) - content = f'Current block: n°{current["number"]}, generated on {block_gen}\n\ -Generation of next block n°{diffi["block"]} \ -possible by at least {issuers}/{len(diffi["levels"])} members\n\ -Common Proof-of-Work difficulty level: {current["powMin"]}, hash starting with `{match}`\n\ -{table.draw()}' + content = f"Current block: n°{current['number']}, generated on {block_gen}\n\ +Generation of next block n°{diffi['block']} \ +possible by at least {issuers}/{len(diffi['levels'])} members\n\ +Common Proof-of-Work difficulty level: {current['powMin']}, hash starting with `{match}`\n\ +{table.draw()}" print(content) diff --git a/silkaj/money/history.py b/silkaj/money/history.py index d1a35ae0..748f2775 100644 --- a/silkaj/money/history.py +++ b/silkaj/money/history.py @@ -110,8 +110,8 @@ def generate_header(pubkey: str, currency_symbol: str, ud_value: int) -> str: balance = get_amount_from_pubkey(pubkey) balance_ud = round(balance[1] / ud_value, 2) date = arrow.now().format(ALL) - return f'Transactions history from: {idty["uid"]} {gen_pubkey_checksum(pubkey)}\n\ -Current balance: {balance[1] / 100} {currency_symbol}, {balance_ud} UD {currency_symbol} on {date}\n' + return f"Transactions history from: {idty['uid']} {gen_pubkey_checksum(pubkey)}\n\ +Current balance: {balance[1] / 100} {currency_symbol}, {balance_ud} UD {currency_symbol} on {date}\n" def get_transactions_history( @@ -319,7 +319,7 @@ def assign_idty_from_pubkey(pubkey: str, identities: list, full_pubkey: bool) -> for identity in identities: if pubkey == identity["pubkey"]: pubkey_mod = gen_pubkey_checksum(pubkey, short=not full_pubkey) - idty = f'{identity["uid"]} - {pubkey_mod}' + idty = f"{identity['uid']} - {pubkey_mod}" return idty diff --git a/silkaj/wot/lookup.py b/silkaj/wot/lookup.py index b8fb81a2..62537082 100644 --- a/silkaj/wot/lookup.py +++ b/silkaj/wot/lookup.py @@ -38,5 +38,5 @@ def lookup_cmd(uid_pubkey: str) -> None: for lookup in lookups: for identity in lookup["uids"]: pubkey_checksum = gen_pubkey_checksum(lookup["pubkey"]) - content += f'\n→ {pubkey_checksum} ↔ {identity["uid"]}' + content += f"\n→ {pubkey_checksum} ↔ {identity['uid']}" click.echo(content) diff --git a/silkaj/wot/status.py b/silkaj/wot/status.py index 0f1db8cf..e0fb2630 100644 --- a/silkaj/wot/status.py +++ b/silkaj/wot/status.py @@ -60,11 +60,11 @@ def status(uid_pubkey: str) -> None: certifications["received_expire"].append( arrow.now().shift(seconds=req_cert["expiresIn"]).format(DATE), ) - certifications["received"].append(f'{lookup_cert["uids"][0]} ✔') + certifications["received"].append(f"{lookup_cert['uids'][0]} ✔") break for pending_cert in req["pendingCerts"]: certifications["received"].append( - f'{(wt.identity_of(pending_cert["from"]))["uid"]} ✘', + f"{(wt.identity_of(pending_cert['from']))['uid']} ✘", ) certifications["received_expire"].append( arrow.get(pending_cert["expires_on"]).to("local").format(DATE), @@ -81,13 +81,13 @@ def status(uid_pubkey: str) -> None: table.fill_from_dict(certifications) print( - f'{identity["uid"]} ({gen_pubkey_checksum(pubkey, True)}) \ -from block #{identity["meta"]["timestamp"][:15]}…\n\ -received {len(certifications["received"])} and sent \ -{nbr_sent_certs}/{params["sigStock"]} certifications:\n\ + f"{identity['uid']} ({gen_pubkey_checksum(pubkey, True)}) \ +from block #{identity['meta']['timestamp'][:15]}…\n\ +received {len(certifications['received'])} and sent \ +{nbr_sent_certs}/{params['sigStock']} certifications:\n\ {table.draw()}\n\ ✔: Certification written in the blockchain\n\ -✘: Pending certification, deadline treatment\n', +✘: Pending certification, deadline treatment\n", ) membership_status(certifications, pubkey, req) -- GitLab