ruff various minor

This commit is contained in:
The MMGen Project 2026-08-07 09:37:48 +00:00
commit 7ae0b988d3
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 12 additions and 13 deletions

View file

@ -75,7 +75,7 @@ def gen_arg_tuple(cfg, func, text):
'cfg': cfg}
for arg in func.__code__.co_varnames:
yield d[arg] if arg in d else text
yield d.get(arg, text)
def make_usage_str(cfg, *, caller):
def gen():

View file

@ -153,11 +153,11 @@ class TokenNew(TokenBase, New):
method = 'eth_estimateGas',
from_addr = self.inputs[0].addr,
data = data)
except Exception as e:
except Exception:
ymsg(
'Unable to estimate gas limit via node. '
'Please retry with --gas set to an integer value, or ‘fallback’ for a sane default')
raise e
raise
return int(res, 16)

View file

@ -161,7 +161,7 @@ class tool_cmd(tool_cmd_base):
from ..obj import TwComment
from ..tw.ctl import TwCtl
ret = await (await TwCtl(self.cfg, self.proto, mode='w')).set_comment(mmgen_or_coin_addr, label)
return True if isinstance(ret, TwComment) else False
return isinstance(ret, TwComment)
async def remove_label(self, mmgen_or_coin_addr: str):
"remove descriptive label for address in tracking wallet"

View file

@ -34,13 +34,13 @@ class Completed(Base):
try:
MMGenTxFile(self).parse(str(filename), quiet_open=quiet_open)
self.check_serialized_integrity()
except Exception as e:
except Exception:
from ..color import orange
from ..util import msg
msg(orange(
f'Something is wrong with transaction file ‘{filename}\n'
'To fix this problem, please move or delete the file'))
raise e
raise
# repeat with sign and send, because coin daemon could be restarted
self.check_correct_chain()

View file

@ -35,14 +35,8 @@ ignore = [
"S110", # `try`-`except`-`pass` detected, consider logging the exception
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM114", # Combine `if` branches using logical `or` operator
"SIM210", # Use `bool(...)` instead of `True if ... else False`
"SIM401", # Use `d.get(arg, text)` instead of an `if` block
"SIM905", # Consider using a list literal instead of `str.split`
"TRY002", # Create your own exception
"TRY201", # Use `raise` without specifying exception name
"UP004", # Class `Binary` inherits from `object`
"UP006", # Use `list` instead of `List` for type annotation
"UP008", # Use `super()` instead of `super(__class__, self)`
"UP022", # Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE`
"UP030", # Use implicit references for positional format fields
"UP031", # Use format specifiers instead of percent format
@ -60,6 +54,11 @@ ignore = [
"mmgen/tool/rpc.py" = [ "RUF013" ] # PEP 484 prohibits implicit `Optional`
"mmgen/contrib/keccak.py" = [ "FURB163" ] # `math.log` -> `math.log2(state.lanew)`
"examples/*" = [ "ASYNC230" ] # open() in async function
"mmgen/proto/eth/rlp/*" = [
"TRY002", # create your own exception
"UP004", # class `Binary` inherits from `object`
"UP008" # Use `super()` instead of `super(__class__, self)`
]
"test/include/common.py" = [
"F821", # undefined name 'cfg'

View file

@ -496,7 +496,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
gldict = globals()
for k in rt_data:
gldict[k] = rt_data[k][coin] if coin in rt_data[k] else None
gldict[k] = rt_data[k].get(coin, None)
self.use_bdb_wallet = self.bdb_wallet or coin != 'btc'