From adeb62b81da6f2747314670985ad7d707a0ae754 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:46 +0000 Subject: [PATCH] ruff C401 (unnecessary generator (rewrite as set comprehension)) --- mmgen/protocol.py | 2 +- mmgen/xmrwallet/ops/__init__.py | 2 +- pyproject.toml | 1 - test/modtest_d/amt.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mmgen/protocol.py b/mmgen/protocol.py index f00927b3..b5e57a48 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -87,7 +87,7 @@ class CoinProtocol(MMGenObject): self.wif_ver_bytes = {k: bytes.fromhex(v) for k, v in self.wif_ver_num.items()} self.wif_ver_bytes_to_pubkey_type = {v: k for k, v in self.wif_ver_bytes.items()} vbs = list(self.wif_ver_bytes.values()) - self.wif_ver_bytes_len = len(vbs[0]) if len(set(len(b) for b in vbs)) == 1 else None + self.wif_ver_bytes_len = len(vbs[0]) if len({len(b) for b in vbs}) == 1 else None if hasattr(self, 'addr_ver_info'): self.addr_ver_bytes = {bytes.fromhex(k): v for k, v in self.addr_ver_info.items()} diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index a4682608..91e87763 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -46,7 +46,7 @@ class OpBase: self.tx_dir = 'txauto_dir' if self.compat_call else 'xmr_tx_dir' classes = tuple(gen_classes()) - self.opts = tuple(set(opt for cls in classes for opt in xmrwallet.opts)) + self.opts = tuple({opt for cls in classes for opt in xmrwallet.opts}) if not hasattr(self, 'stem'): self.stem = self.name diff --git a/pyproject.toml b/pyproject.toml index 2c27f374..4dc6d45b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ ignore = [ "B018", # Found useless expression. Either assign it to a variable or remove it. "B026", # Star-arg unpacking after a keyword argument is strongly discouraged "BLE001", # Do not catch blind exception: `Exception` - "C401", # Unnecessary generator (rewrite as a set comprehension) "C402", # Unnecessary generator (rewrite as a dict comprehension) "C409", # Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) "C410", # Unnecessary list literal passed to `list()` (remove the outer call to `list()`) diff --git a/test/modtest_d/amt.py b/test/modtest_d/amt.py index 253db9bf..d0084383 100755 --- a/test/modtest_d/amt.py +++ b/test/modtest_d/amt.py @@ -14,7 +14,7 @@ from mmgen.amt import TokenAmt from ..include.common import cfg, vmsg def get_protos(data): - return {coin: init_proto(cfg, coin, need_amt=True) for coin in set(d[0] for d in data)} + return {coin: init_proto(cfg, coin, need_amt=True) for coin in {d[0] for d in data}} def test_to_unit(data): protos = get_protos(data)