From 21060b2c928bb9c604fd3337c1aedcf9ee0df921 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 13 Sep 2026 15:50:13 +0000 Subject: [PATCH] add `scripts` dir to ruff check --- .github/workflows/lint.yaml | 1 + pyproject.toml | 1 + scripts/compute-file-chksum.py | 4 +--- scripts/create-bip-hd-chain-params.py | 8 ++++---- scripts/create-token.py | 6 +++--- scripts/exec_wrapper.py | 12 ++++++------ test/test-release.d/cfg.sh | 1 + 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 6d2fceef..23ed2ae7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -54,6 +54,7 @@ jobs: ruff check --output-format=github setup.py ruff check --output-format=github mmgen ruff check --output-format=github examples + ruff check --output-format=github scripts ruff check --output-format=github test - name: Check code vulnerabilities with Bandit static analyzer diff --git a/pyproject.toml b/pyproject.toml index 67c2e34a..1cdf77de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ ignore = [ "protobuf.py" = [ "UP045" ] # Use `X | None` for type annotations "mmgen/rpc/backends/curl.py" = [ "ASYNC221" ] # blocking method in async function "mmgen/tool/*" = [ "F821" ] # Undefined name `sstr` +"create-bip-hd-chain-params.py" = [ "F401" ] "examples/*" = [ "ASYNC230" ] # open() in async function diff --git a/scripts/compute-file-chksum.py b/scripts/compute-file-chksum.py index eb46d25e..e868a2b4 100755 --- a/scripts/compute-file-chksum.py +++ b/scripts/compute-file-chksum.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 -import sys, os - -import script_init +import script_init # noqa from mmgen.main import launch from mmgen.cfg import Config from mmgen.util import msg, Msg, make_chksum_6 diff --git a/scripts/create-bip-hd-chain-params.py b/scripts/create-bip-hd-chain-params.py index 88289a7f..105c3078 100755 --- a/scripts/create-bip-hd-chain-params.py +++ b/scripts/create-bip-hd-chain-params.py @@ -45,7 +45,7 @@ dfl_curve = 'secp' dfl_dfl_path = "0'/0/0" def get_bip_utils_data(bipnum, n): - name, v = bip_utils_data[bipnum][n] + _, v = bip_utils_data[bipnum][n] vb_prv = v.m_key_net_ver.m_priv_net_ver.hex() vb_pub = v.m_key_net_ver.m_pub_net_ver.hex() ap = v.m_addr_params @@ -71,11 +71,11 @@ def gen(): fs = '{:<6} {:6} {:1} {}' - yield f'[defaults]' + yield '[defaults]' yield fs.format('IDX', 'CHAIN', hdr2, 'NAME') yield fs.format('0', '-', fs2.format(dfl_curve, '-', '-', dfl_vb_prv, dfl_vb_pub, '-', '-', dfl_dfl_path), '-') - yield f'\n[bip-44]' + yield '\n[bip-44]' yield fs.format('IDX', 'CHAIN', hdr2, 'NAME') for k, v in slip44_data.items(): if int(k) in bip_utils_data[44]: @@ -88,7 +88,7 @@ def gen(): nd = v[1].m_coin_names yield format_data(bipnum, n, nd.m_abbr, nd.m_name) - yield f'\n[bip-44-unsupported]' + yield '\n[bip-44-unsupported]' yield fs.format('IDX', 'CHAIN', '', 'NAME') for k, v in slip44_data.items(): if not int(k) in bip_utils_data[44]: diff --git a/scripts/create-token.py b/scripts/create-token.py index 80c6a4e8..aa9fd725 100755 --- a/scripts/create-token.py +++ b/scripts/create-token.py @@ -24,7 +24,7 @@ import sys, json, re from subprocess import run, PIPE from collections import namedtuple -import script_init +import script_init # noqa from mmgen.main import launch from mmgen.cfg import Config from mmgen.util import Msg, msg, rmsg, ymsg, die @@ -133,7 +133,7 @@ def compile_code(cfg, code): cmd += ['--output-dir', cfg.outdir or '.'] cmd += ['-'] msg(f"Executing: {' '.join(cmd)}") - cp = run(cmd, input=code.encode(), stdout=PIPE, stderr=PIPE) + cp = run(cmd, input=code.encode(), capture_output=True) out = cp.stdout.decode().replace('\r', '') err = cp.stderr.decode().replace('\r', '').strip() if cp.returncode != 0: @@ -159,7 +159,7 @@ def main(): if not cfg._proto.coin in ('ETH', 'ETC'): die(1, '--coin option must be ETH or ETC') - if not len(cfg._args) == 1: + if len(cfg._args) != 1: cfg._usage() code = create_src(cfg, solidity_code_template, token_data) diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index 332260dd..7b2fad11 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -60,12 +60,12 @@ def exec_wrapper_write_traceback(e, exit_val): def gen_output(): yield 'Traceback (most recent call last):' - for e in traceback.extract_tb(sys.exc_info()[2]): + for d in traceback.extract_tb(sys.exc_info()[2]): yield ' File "{f}", line {l}, in {n}\n {L}'.format( - f = exec_wrapper_execed_file if e.filename == '' else fixup_fn(e.filename), - l = '(scrubbed)' if os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC') else e.lineno, - n = e.name, - L = e.line or 'N/A') + f = exec_wrapper_execed_file if d.filename == '' else fixup_fn(d.filename), + l = '(scrubbed)' if os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC') else d.lineno, + n = d.name, + L = d.line or 'N/A') tb_lines = list(gen_output()) @@ -152,7 +152,7 @@ try: exec_wrapper_sys.argv.pop(0) exec_wrapper_execed_file = exec_wrapper_sys.argv[0] with open(exec_wrapper_execed_file) as fp: - exec(fp.read()) + exec(fp.read()) # noqa except SystemExit as e: exec_wrapper_do_exit(e, e.code) except Exception as e: diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index 16757119..f99cccc1 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -77,6 +77,7 @@ init_tests() { - $ruff check setup.py - $ruff check mmgen - $ruff check examples + - $ruff check scripts - $ruff check test "