From 5bdf32ce41497da2383c115d9a42dc31e40fbe37 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 10 Aug 2026 09:54:34 +0000 Subject: [PATCH] ruff PLC0206 (extracting value from dictionary without calling `.items()`) --- mmgen/addrdata.py | 4 ++-- mmgen/msg.py | 4 ++-- pyproject.toml | 1 - test/cmdtest_d/include/cfg.py | 12 ++++++------ test/cmdtest_d/regtest.py | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mmgen/addrdata.py b/mmgen/addrdata.py index 7a927449..6311fee4 100755 --- a/mmgen/addrdata.py +++ b/mmgen/addrdata.py @@ -98,12 +98,12 @@ class TwAddrData(AddrData, metaclass=AsyncInit): self.cfg._util.vmsg(f'{i} {gc.proj_name} addresses found, {len(twd)} accounts total') - for al_id in out: + for al_id, data in out.items(): self.add(AddrList( self.cfg, self.proto, al_id = al_id, - adata = AddrListData(sorted(out[al_id], key=lambda a: a.idx)))) + adata = AddrListData(sorted(data, key=lambda a: a.idx)))) class TwAddrDataWithStore(TwAddrData): diff --git a/mmgen/msg.py b/mmgen/msg.py index cf3e754c..b189a187 100755 --- a/mmgen/msg.py +++ b/mmgen/msg.py @@ -150,9 +150,9 @@ class coin_msg: 'sig': 'signature:'} def gen_entry(e): - for k in labels: + for k, v in labels.items(): if e.get(k): - yield fs_sig.format(labels[k], e[k]) + yield fs_sig.format(v, e[k]) def gen_all(): for k, v in hdr_data.items(): diff --git a/pyproject.toml b/pyproject.toml index 6ff6d995..7273d983 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ ignore = [ "I001", # Import block is un-sorted or un-formatted "ISC004", # Unparenthesized implicit string concatenation in collection "N999", # Invalid module name: 'import'... - "PLC0206", # Extracting value from dictionary without calling `.items()` "PLW1510", # `subprocess.run` without explicit `check` argument "RET501", # Do not explicitly `return None` in function if it is the only possible return value "RUF012", # Mutable default value for class attribute diff --git a/test/cmdtest_d/include/cfg.py b/test/cmdtest_d/include/cfg.py index 852761f3..775f8f0e 100755 --- a/test/cmdtest_d/include/cfg.py +++ b/test/cmdtest_d/include/cfg.py @@ -267,8 +267,8 @@ cfgs = { # addr_idx_lists (except 31, 32, 33, 34) must contain exactly 8 address def fixup_cfgs(): import os - for k in cfgs: - cfgs[k]['tmpdir'] = os.path.join('test', 'tmp', str(k)) + for k, v in cfgs.items(): + v['tmpdir'] = os.path.join('test', 'tmp', str(k)) for src, target in ( ('6', '11'), @@ -280,11 +280,11 @@ def fixup_cfgs(): cfgs[target].update(cfgs[src]) cfgs[target]['tmpdir'] = os.path.join('test', 'tmp', target) - for k in cfgs: - cfgs[k]['segwit'] = randbool() if cfg.segwit_random else bool(cfg.segwit or cfg.bech32) + for k, v in cfgs.items(): + v['segwit'] = randbool() if cfg.segwit_random else bool(cfg.segwit or cfg.bech32) if cfg.debug_utf8: - for k in cfgs: - cfgs[k]['tmpdir'] += '-α' + for k, v in cfgs.items(): + v['tmpdir'] += '-α' fixup_cfgs() diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 0110f880..ee37001d 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -495,8 +495,8 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): self.proto = init_proto(cfg, coin, network='regtest', need_amt=True) gldict = globals() - for k in rt_data: - gldict[k] = rt_data[k].get(coin, None) + for k, v in rt_data.items(): + gldict[k] = v.get(coin, None) self.use_bdb_wallet = self.bdb_wallet or coin != 'btc'