add scripts dir to ruff check

This commit is contained in:
The MMGen Project 2026-09-13 15:50:13 +00:00
commit 21060b2c92
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 17 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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 == '<string>' 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 == '<string>' 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:

View file

@ -77,6 +77,7 @@ init_tests() {
- $ruff check setup.py
- $ruff check mmgen
- $ruff check examples
- $ruff check scripts
- $ruff check test
"