ruff C402 (unnecessary generator (rewrite as dict comprehension))
This commit is contained in:
parent
adeb62b81d
commit
de4937b82c
8 changed files with 9 additions and 14 deletions
|
|
@ -213,7 +213,7 @@ class MMGenListItem(MMGenObject):
|
|||
return object.__setattr__(self, name, value)
|
||||
|
||||
def _asdict(self):
|
||||
return dict((k, v) for k, v in self.__dict__.items() if k in self.valid_attrs)
|
||||
return {k: v for k, v in self.__dict__.items() if k in self.valid_attrs}
|
||||
|
||||
class MMGenRange(tuple, InitErrors, MMGenObject):
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ def negated_opts(opts, data={}):
|
|||
if data:
|
||||
return data
|
||||
else:
|
||||
data.update(dict(
|
||||
((k[3:] if k.startswith('no-') else f'no-{k}'), v)
|
||||
data.update({
|
||||
(k[3:] if k.startswith('no-') else f'no-{k}'): v
|
||||
for k, v in opts.items()
|
||||
if len(k) > 1 and not v.has_parm))
|
||||
if len(k) > 1 and not v.has_parm})
|
||||
return data
|
||||
|
||||
def get_opt_by_substring(opt, opts):
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit):
|
|||
self.cfg, fn, desc='daemon config file', silent=not self.cfg.verbose)
|
||||
except:
|
||||
self.cfg._util.vmsg(f'Warning: {fn!r} does not exist or is unreadable')
|
||||
return dict((k, None) for k in req_keys)
|
||||
return {k: None for k in req_keys}
|
||||
|
||||
def gen():
|
||||
for key in req_keys:
|
||||
|
|
|
|||
|
|
@ -204,11 +204,7 @@ class BaseSerializable(collections.abc.Sequence):
|
|||
_cached_rlp = None
|
||||
|
||||
def as_dict(self):
|
||||
return dict(
|
||||
(field, value)
|
||||
for field, value
|
||||
in zip(self._meta.field_names, self)
|
||||
)
|
||||
return {field: value for field, value in zip(self._meta.field_names, self)}
|
||||
|
||||
def __iter__(self):
|
||||
for attr in self._meta.field_attrs:
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit):
|
|||
|
||||
@property
|
||||
def mmid_ordered_dict(self):
|
||||
return dict((x['mmid'], {'addr': x['addr'], 'comment': x['comment']}) for x in self.sorted_list)
|
||||
return {x['mmid']: {'addr': x['addr'], 'comment': x['comment']} for x in self.sorted_list}
|
||||
|
||||
async def get_label_addr_pairs(self):
|
||||
return [label_addr_pair(
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ def is_utf8(s):
|
|||
return True
|
||||
|
||||
def remove_whitespace(s, *, ws='\t\r\n '):
|
||||
return s.translate(dict((ord(e), None) for e in ws))
|
||||
return s.translate({ord(e): None for e in ws})
|
||||
|
||||
def strip_comment(line):
|
||||
return re.sub('#.*', '', line).rstrip()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class MoneroMMGenFile:
|
|||
|
||||
def make_chksum(self, *, keys=None):
|
||||
res = json.dumps(
|
||||
dict((k, v) for k, v in self.data._asdict().items() if (not keys or k in keys)),
|
||||
{k: v for k, v in self.data._asdict().items() if (not keys or k in keys)},
|
||||
cls = json_encoder)
|
||||
return make_chksum_N(res, rounds=1, nchars=self.chksum_nchars, upper=False)
|
||||
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
"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()`)
|
||||
"C414", # Unnecessary `list()` call within `set()`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue