From e60a89d6475fed0843c9110a8e8f1e183d4d5477 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Aug 2026 09:37:48 +0000 Subject: [PATCH] ruff SIM201 (use `a != b` instead of `not a == b`) --- mmgen/autosign/__init__.py | 2 +- mmgen/proto/btc/rpc/local.py | 5 ++--- mmgen/proto/btc/tx/unsigned.py | 2 +- mmgen/proto/eth/tx/new.py | 2 +- mmgen/swap/proto/thorchain/thornode.py | 2 +- mmgen/tool/file.py | 2 +- mmgen/tx/keys.py | 2 +- mmgen/util.py | 2 +- pyproject.toml | 1 - test/cmdtest_d/autosign.py | 2 +- test/cmdtest_d/cfgfile.py | 2 +- test/cmdtest_d/ethdev.py | 8 ++++---- test/cmdtest_d/ref_altcoin.py | 2 +- test/cmdtest_d/regtest.py | 2 +- test/cmdtest_d/tool.py | 2 +- test/objtest.py | 2 +- 16 files changed, 19 insertions(+), 21 deletions(-) diff --git a/mmgen/autosign/__init__.py b/mmgen/autosign/__init__.py index acbeb2da..ada03325 100755 --- a/mmgen/autosign/__init__.py +++ b/mmgen/autosign/__init__.py @@ -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!') diff --git a/mmgen/proto/btc/rpc/local.py b/mmgen/proto/btc/rpc/local.py index 7db35a6a..7a434df0 100755 --- a/mmgen/proto/btc/rpc/local.py +++ b/mmgen/proto/btc/rpc/local.py @@ -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]() diff --git a/mmgen/proto/btc/tx/unsigned.py b/mmgen/proto/btc/tx/unsigned.py index b19ef572..75157275 100755 --- a/mmgen/proto/btc/tx/unsigned.py +++ b/mmgen/proto/btc/tx/unsigned.py @@ -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 diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index c31feb76..4b507653 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -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' diff --git a/mmgen/swap/proto/thorchain/thornode.py b/mmgen/swap/proto/thorchain/thornode.py index 4a9401a7..efc68ec2 100755 --- a/mmgen/swap/proto/thorchain/thornode.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -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', diff --git a/mmgen/tool/file.py b/mmgen/tool/file.py index 785b8e6e..1d2f9fa7 100755 --- a/mmgen/tool/file.py +++ b/mmgen/tool/file.py @@ -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: diff --git a/mmgen/tx/keys.py b/mmgen/tx/keys.py index b6a2a7a7..1ebcdc09 100755 --- a/mmgen/tx/keys.py +++ b/mmgen/tx/keys.py @@ -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: diff --git a/mmgen/util.py b/mmgen/util.py index b89876c2..72d8c971 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index be3cc08c..af68bbe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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` diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index 43c62c44..c4ee7395 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -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')) diff --git a/test/cmdtest_d/cfgfile.py b/test/cmdtest_d/cfgfile.py index fbccb548..4edb378d 100755 --- a/test/cmdtest_d/cfgfile.py +++ b/test/cmdtest_d/cfgfile.py @@ -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 diff --git a/test/cmdtest_d/ethdev.py b/test/cmdtest_d/ethdev.py index aa771752..d1459453 100755 --- a/test/cmdtest_d/ethdev.py +++ b/test/cmdtest_d/ethdev.py @@ -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:], diff --git a/test/cmdtest_d/ref_altcoin.py b/test/cmdtest_d/ref_altcoin.py index 486a5ef8..5c2e0833 100755 --- a/test/cmdtest_d/ref_altcoin.py +++ b/test/cmdtest_d/ref_altcoin.py @@ -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' diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 4f096db4..7cca0c77 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -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']) diff --git a/test/cmdtest_d/tool.py b/test/cmdtest_d/tool.py index 0b86e1a5..44329ce9 100755 --- a/test/cmdtest_d/tool.py +++ b/test/cmdtest_d/tool.py @@ -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 diff --git a/test/objtest.py b/test/objtest.py index 744bdffb..0e12b295 100755 --- a/test/objtest.py +++ b/test/objtest.py @@ -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: