ruff SIM201 (use a != b instead of not a == b)
This commit is contained in:
parent
819ddf96d2
commit
e60a89d647
16 changed files with 19 additions and 21 deletions
|
|
@ -204,7 +204,7 @@ class Autosign:
|
|||
def check_or_create(dirname):
|
||||
path = getattr(self, dirname)
|
||||
if path.is_dir():
|
||||
if not path.stat().st_mode & S_IWUSR|S_IRUSR == S_IWUSR|S_IRUSR:
|
||||
if path.stat().st_mode & S_IWUSR|S_IRUSR != S_IWUSR|S_IRUSR:
|
||||
die(1, f'‘{path}’ is not read/write for this user!')
|
||||
elif path.exists():
|
||||
die(1, f'‘{path}’ is not a directory!')
|
||||
|
|
|
|||
|
|
@ -389,8 +389,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit):
|
|||
if 'deployment_info' in self.caps:
|
||||
return (
|
||||
self.cached['deploymentinfo']['deployments']['segwit']['active']
|
||||
or (self.cfg.test_suite and not self.chain == 'regtest')
|
||||
)
|
||||
or (self.cfg.test_suite and self.chain != 'regtest'))
|
||||
|
||||
d = self.cached['blockchaininfo']
|
||||
|
||||
|
|
@ -406,7 +405,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit):
|
|||
except:
|
||||
pass
|
||||
|
||||
return self.cfg.test_suite and not self.chain == 'regtest'
|
||||
return self.cfg.test_suite and self.chain != 'regtest'
|
||||
|
||||
return locals()[info_id]()
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Unsigned(Completed, TxBase.Unsigned):
|
|||
tx_decoded = await self.rpc.call('decoderawtransaction', ret['hex'])
|
||||
new.compare_size_and_estimated_size(tx_decoded)
|
||||
new.coin_txid = CoinTxID(self.deserialized.txid)
|
||||
if not new.coin_txid == tx_decoded['txid']:
|
||||
if new.coin_txid != tx_decoded['txid']:
|
||||
die('BadMMGenTxID', 'txid mismatch (after signing)')
|
||||
msg('OK')
|
||||
return new
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class New(VmNew, Base, TxBase.New):
|
|||
self.gas = int(self.cfg.gas)
|
||||
elif self.cfg.gas == 'fallback':
|
||||
self.gas = self.dfl_gas
|
||||
elif self.is_bump and not self.rpc.daemon.id == 'reth':
|
||||
elif self.is_bump and self.rpc.daemon.id != 'reth':
|
||||
self.gas = self.txobj['startGas']
|
||||
else:
|
||||
assert self.cfg.gas in ('auto', None), f'{self.cfg.gas}: invalid value for cfg.gas'
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Thornode:
|
|||
|
||||
if (
|
||||
(self.tx.proto.tokensym or self.tx.recv_asset.tokensym)
|
||||
and not self.tx.send_asset.chain == 'THOR'): # token swap
|
||||
and self.tx.send_asset.chain != 'THOR'): # token swap
|
||||
in_data = get_data(
|
||||
self.tx.send_asset.full_name,
|
||||
'THOR.RUNE',
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
def _file_chksum(self, mmgen_addrfile, obj):
|
||||
kwargs = {'skip_chksum_msg': True}
|
||||
if not obj.__name__ == 'PasswordList':
|
||||
if obj.__name__ != 'PasswordList':
|
||||
kwargs.update({'key_address_validity_check': False})
|
||||
ret = obj(self.cfg, self.proto, infile=mmgen_addrfile, **kwargs)
|
||||
if self.cfg.verbose:
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class TxKeys:
|
|||
self.cfg._util.qmsg(f'Need seed data for Seed ID {sid}')
|
||||
seed = Wallet(self.cfg, passwd_file=self.passwdfile).seed
|
||||
msg(f'User input produced Seed ID {seed.sid}')
|
||||
if not seed.sid == sid: # TODO: add test
|
||||
if seed.sid != sid: # TODO: add test
|
||||
seed = seed.subseed_by_seed_id(sid, print_msg=True)
|
||||
|
||||
if seed:
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class Util:
|
|||
die_on_fail = False,
|
||||
verbose = False):
|
||||
|
||||
if not chk1 == chk2:
|
||||
if chk1 != chk2:
|
||||
fs = "{} ERROR: {} checksum ({}) doesn't match {} checksum ({})"
|
||||
m = fs.format((hdr+':\n ' if hdr else 'CHECKSUM'), desc2, chk2, desc1, chk1)
|
||||
if die_on_fail:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
"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
|
||||
"SIM905", # Consider using a list literal instead of `str.split`
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
|
|||
ext = '.testnet.rawtx' if fn.endswith('.testnet.rawtx') else '.rawtx'
|
||||
fn = fn[:-len(ext)] + '-α' + ext
|
||||
target = joinpath(self.asi.tx_dir, fn)
|
||||
if not op == 'remove_signed':
|
||||
if op != 'remove_signed':
|
||||
shutil.copyfile(src, target)
|
||||
try:
|
||||
os.unlink(target.replace('.rawtx', '.sigtx'))
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class CmdTestCfgFile(CmdTestBase):
|
|||
self.write_to_cfgfile('usr', ['foo true', 'bar false'])
|
||||
t = self.old_sample_common(
|
||||
old_set = True,
|
||||
pexpect_spawn = not gc.platform == 'win32')
|
||||
pexpect_spawn = gc.platform != 'win32')
|
||||
t.expect('unrecognized option')
|
||||
return t
|
||||
|
||||
|
|
|
|||
|
|
@ -965,7 +965,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
return self._addrimport_one_addr(addr=dfl_devaddr)
|
||||
|
||||
def addrimport_reth_devaddr(self):
|
||||
if not self.daemon.id == 'reth':
|
||||
if self.daemon.id != 'reth':
|
||||
return 'silent'
|
||||
return self._addrimport_one_addr(addr=reth_devaddr)
|
||||
|
||||
|
|
@ -1076,7 +1076,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
return t
|
||||
|
||||
def del_reth_devaddr(self):
|
||||
if not self.daemon.id == 'reth':
|
||||
if self.daemon.id != 'reth':
|
||||
return 'silent'
|
||||
return self._del_addr(reth_devaddr)
|
||||
|
||||
|
|
@ -1190,7 +1190,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
'0x' + addr,
|
||||
'0x' + self.message.encode().hex())
|
||||
|
||||
if not self.daemon.id == 'geth':
|
||||
if self.daemon.id != 'geth':
|
||||
return 'skip'
|
||||
|
||||
self.spawn(msg_only=True)
|
||||
|
|
@ -1702,7 +1702,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
|||
def edit_comment1(self):
|
||||
return self.edit_comment(out_num=del_addrs[0], comment_text=tw_comment_zh[:3])
|
||||
def edit_comment2(self):
|
||||
spawn = not gc.platform == 'win32'
|
||||
spawn = gc.platform != 'win32'
|
||||
return self.edit_comment(
|
||||
out_num = del_addrs[0],
|
||||
comment_text = tw_comment_zh[3:],
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class CmdTestRefAltcoin(CmdTestRef, CmdTestBase):
|
|||
extra_desc = f'{proto.coin}{token_desc} {proto.network}')
|
||||
t.read()
|
||||
t.ok()
|
||||
if proto.sign_mode == 'daemon' and not proto.network_id == 'btc':
|
||||
if proto.sign_mode == 'daemon' and proto.network_id != 'btc':
|
||||
stop_test_daemons(proto.network_id, remove_datadir=True)
|
||||
return 'ok'
|
||||
|
||||
|
|
|
|||
|
|
@ -2273,7 +2273,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
|
|||
return self._user_dump_hex_send_cli('bob', subdir='nochg_tx')
|
||||
|
||||
def bob_bal7(self):
|
||||
if not self.coin == 'btc':
|
||||
if self.coin != 'btc':
|
||||
return 'skip'
|
||||
return self._user_bal_cli('bob', chks=['499.99990287', '46.51845565'])
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class CmdTestTool(CmdTestMain, CmdTestBase):
|
|||
vmsg(f'Incog ID: {cyan(i_id)}')
|
||||
t = self.spawn('mmgen-tool', ['-d', self.tmpdir, 'find_incog_data', f1, i_id])
|
||||
o = t.expect_getend(f'Incog data for ID {i_id} found at offset ')
|
||||
if not gc.platform == 'win32':
|
||||
if gc.platform != 'win32':
|
||||
os.unlink(f1) # causes problems with MSYS2
|
||||
cmp_or_die(hincog_offset, int(o))
|
||||
return t
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ def run_test(mod, test, arg, input_data, arg1, exc_name):
|
|||
except Exception as e:
|
||||
if input_data == 'good':
|
||||
raise ValueError(f'Error on good input data: {e}') from e
|
||||
if not type(e).__name__ == exc_name:
|
||||
if type(e).__name__ != exc_name:
|
||||
msg(f'Incorrect exception: expected {exc_name} but got {type(e).__name__}')
|
||||
raise
|
||||
if cfg.super_silent:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue