From 7ae0b988d353c9b31b9d0aad1349b6a55e5b67c8 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:48 +0000 Subject: [PATCH] ruff various minor --- mmgen/help/__init__.py | 2 +- mmgen/proto/eth/tx/new.py | 4 ++-- mmgen/tool/rpc.py | 2 +- mmgen/tx/completed.py | 4 ++-- pyproject.toml | 11 +++++------ test/cmdtest_d/regtest.py | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mmgen/help/__init__.py b/mmgen/help/__init__.py index c4f13cb1..a5865967 100755 --- a/mmgen/help/__init__.py +++ b/mmgen/help/__init__.py @@ -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(): diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 4b507653..8edd5c27 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -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) diff --git a/mmgen/tool/rpc.py b/mmgen/tool/rpc.py index 282bb5f0..48dddb9b 100755 --- a/mmgen/tool/rpc.py +++ b/mmgen/tool/rpc.py @@ -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" diff --git a/mmgen/tx/completed.py b/mmgen/tx/completed.py index f18e32ec..373edf56 100755 --- a/mmgen/tx/completed.py +++ b/mmgen/tx/completed.py @@ -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() diff --git a/pyproject.toml b/pyproject.toml index af68bbe9..2f275174 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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' diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 7cca0c77..0110f880 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -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'