ruff C401 (unnecessary generator (rewrite as set comprehension))

This commit is contained in:
The MMGen Project 2026-08-07 09:37:46 +00:00
commit adeb62b81d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 3 additions and 4 deletions

View file

@ -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()}

View file

@ -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

View file

@ -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()`)

View file

@ -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)