From 819ddf96d28de7248bc2022c6b0607f2fb4d5f3b Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:48 +0000 Subject: [PATCH] ruff SIM118 (use `key in dict` instead of `key in dict.keys()) --- mmgen/msg.py | 2 +- pyproject.toml | 1 - test/altcointest.py | 2 +- test/tooltest2.py | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mmgen/msg.py b/mmgen/msg.py index 353991b3..cf3e754c 100755 --- a/mmgen/msg.py +++ b/mmgen/msg.py @@ -196,7 +196,7 @@ class coin_msg: fs_hdr = '{:%s} {}' % max(len(v[0]) for v in hdr_data.values()) fs_sig = '%s{:%s} %s{}' % ( ' ' * (2 if req_addr else 5), - max(len(labels[k]) for v in self.sigs.values() for k in v.keys()), + max(len(labels[k]) for v in self.sigs.values() for k in v), self.msg_cls.sigdata_pfx or '' ) if self.sigs else None diff --git a/pyproject.toml b/pyproject.toml index ebdaf61b..be3cc08c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,6 @@ 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 - "SIM118", # Use `key in dict` instead of `key in dict.keys()` "SIM201", # Use `path.stat().st_mode & S_IWUSR | S_IRUSR != S_IWUSR | S_IRUSR` instead of `not path.stat().st_mode & S_IWUSR | S_IRUSR == S_IWUSR | S_IRUSR` "SIM210", # Use `bool(...)` instead of `True if ... else False` "SIM401", # Use `d.get(arg, text)` instead of an `if` block diff --git a/test/altcointest.py b/test/altcointest.py index 7c3bf2b3..0ddf0053 100755 --- a/test/altcointest.py +++ b/test/altcointest.py @@ -269,7 +269,7 @@ class TestCoinInfo(CoinInfo): if isinstance(e['p2sh_info'], tuple): fix_ver_info(e, 'p2sh_info') - for k in e.keys(): + for k in e: e[k] = repr(e[k]) e[k] = re.sub(r"'0x(..)'", r'0x\1', e[k]) e[k] = re.sub(r"'0x(....)'", r'0x\1', e[k]) diff --git a/test/tooltest2.py b/test/tooltest2.py index fcccdf49..26c93fbc 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -337,9 +337,9 @@ if cfg.tool_api: if cfg.list_tests: Msg('Available tests:') - for modname in main_tool.mods.keys(): + for modname in main_tool.mods: cls = importlib.import_module(f'mmgen.tool.{modname}').tool_cmd - Msg(f' {modname:6} - {docstring_head(cls)}') + Msg(f' {modname:10} - {docstring_head(cls)}') sys.exit(0) if cfg.list_tested_cmds: