From 79c538d6760aaf66e219adca116c24810ee2bd90 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 15 Aug 2026 14:13:09 +0000 Subject: [PATCH] pylint fixes --- mmgen/addrlist.py | 2 +- mmgen/fileutil.py | 2 +- mmgen/led.py | 4 +- mmgen/proto/eth/tx/base.py | 1 - mmgen/proto/eth/tx/new.py | 2 +- mmgen/term.py | 5 +- mmgen/tool/util.py | 2 +- mmgen/util2.py | 2 +- mmgen/xmrwallet/ops/__init__.py | 2 + pyproject.toml | 76 ++-------------------------- test/cmdtest_d/autosign.py | 2 +- test/cmdtest_d/httpd/thornode/rpc.py | 2 +- test/cmdtest_d/include/runner.py | 2 +- test/cmdtest_d/regtest.py | 4 +- test/gentest.py | 2 +- test/modtest_d/tx.py | 4 +- 16 files changed, 26 insertions(+), 88 deletions(-) diff --git a/mmgen/addrlist.py b/mmgen/addrlist.py index 21ec3b39..7e919132 100755 --- a/mmgen/addrlist.py +++ b/mmgen/addrlist.py @@ -149,7 +149,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID has_keys = False chksum_rec_f = lambda foo, e: (str(e.idx), e.addr.views[e.addr.view_pref]) - def dmsg_sc(self, desc, data): + def dmsg_sc(self, desc, data): # pylint: disable=method-hidden Msg(f'sc_debug_{desc}: {data}') def noop(self, desc, data): diff --git a/mmgen/fileutil.py b/mmgen/fileutil.py index 1253a779..048af79a 100755 --- a/mmgen/fileutil.py +++ b/mmgen/fileutil.py @@ -217,7 +217,7 @@ def write_data_to_file( msg('Redirecting output to file') if binary and gc.platform == 'win32': - import msvcrt + import msvcrt # pylint: disable=import-error msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) # MSWin workaround. See msg_r() diff --git a/mmgen/led.py b/mmgen/led.py index 4b01168e..4ae1e6c2 100755 --- a/mmgen/led.py +++ b/mmgen/led.py @@ -206,7 +206,7 @@ class LEDControl: msg('\n') return - def set(self, state): + def set(self, state): # pylint: disable=method-hidden lt = namedtuple('led_timings', ['on_secs', 'off_secs']) timings = { 'off': lt(0, 0), @@ -230,7 +230,7 @@ class LEDControl: self.led_thread.start() - def stop(self): + def stop(self): # pylint: disable=method-hidden self.set('off') self.ev.set() diff --git a/mmgen/proto/eth/tx/base.py b/mmgen/proto/eth/tx/base.py index 57fa23b5..4d4284d0 100755 --- a/mmgen/proto/eth/tx/base.py +++ b/mmgen/proto/eth/tx/base.py @@ -21,7 +21,6 @@ class Base(TxBase): rel_fee_desc = 'gas price' rel_fee_disp = 'gas price in Gwei' - txobj = None dfl_gas = 21000 # the startGas amt used in the transaction # for simple sends with no data, startGas = 21000 contract_desc = 'contract' diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 8edd5c27..c41fa68a 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -127,7 +127,7 @@ class TokenNew(TokenBase, New): if self.is_swap and (force or not hasattr(self, 'router_gas')): self.router_gas = ( int(self.cfg.router_gas) if self.cfg.router_gas else - self.txobj['router_gas'] if self.txobj else + self.txobj['router_gas'] if hasattr(self, 'txobj') else self.dfl_router_gas) @property diff --git a/mmgen/term.py b/mmgen/term.py index df697e1f..9bd02d76 100755 --- a/mmgen/term.py +++ b/mmgen/term.py @@ -35,7 +35,7 @@ match gc.platform: hold_protect_timeout = 2 if gc.platform == 'darwin' else 0.3 case 'win32': try: - import msvcrt + import msvcrt # pylint: disable=import-error except: die(2, 'Unable to set terminal mode') if not sys.stdin.isatty(): @@ -304,3 +304,6 @@ def init_term(cfg, *, noecho=False): def reset_term(): get_term().reset() + +# required by pylint: +get_char = get_char_raw = kb_hold_protect = get_terminal_size = lambda *args, **kwargs: None diff --git a/mmgen/tool/util.py b/mmgen/tool/util.py index a0263355..284457af 100755 --- a/mmgen/tool/util.py +++ b/mmgen/tool/util.py @@ -128,7 +128,7 @@ class tool_cmd(tool_cmd_base): def unhexdump(self, infile: str): "decode hexdump from file (use '-' for stdin) (warning: outputs binary data)" if gc.platform == 'win32': - import sys, msvcrt + import sys, msvcrt # pylint: disable=import-error msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) from ..fileutil import get_data_from_file from ..util2 import decode_pretty_hexdump diff --git a/mmgen/util2.py b/mmgen/util2.py index dfcdda6c..3ac644da 100755 --- a/mmgen/util2.py +++ b/mmgen/util2.py @@ -94,7 +94,7 @@ def get_keccak(cfg=None, cached_ret=[]): from .contrib.keccak import keccak_256 elif not (keccak_256 := get_hashlib_keccak()): load_cryptodome() - from Crypto.Hash import keccak + from Crypto.Hash import keccak # pylint: disable=import-error keccak_256 = lambda data: keccak.new(data=data, digest_bytes=32) cached_ret.append(keccak_256) diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index 91e87763..e6e83a79 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -23,6 +23,8 @@ from ... import xmrwallet from .. import uarg_info +fmt_amt = hl_amt = lambda *args, **kwargs: None # pylint + class OpBase: opts = ('wallet_dir',) diff --git a/pyproject.toml b/pyproject.toml index 9f8c311a..3e83d6c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,86 +84,20 @@ errors-only = true jobs = 0 ignore = [ "data", - "wordlist", - "pyethereum", - "rlp", - "tx.py", ] -ignored-modules = [ # ignored for no-member, otherwise checked +extension-pkg-allow-list = [ "mmgen.proto.secp256k1.secp256k1", - "mmgen.term", - "msvcrt", "gmpy2", ] [tool.pylint."messages control"] disable = [ - "raw-checker-failed", - "bad-inline-option", - "locally-disabled", - "file-ignored", - "suppressed-message", - "useless-suppression", - "deprecated-pragma", - "use-symbolic-message-instead", - "use-implicit-booleaness-not-comparison-to-string", - "use-implicit-booleaness-not-comparison-to-zero", - "not-async-context-manager", -# non-default: "no-method-argument", + "no-self-argument", "function-redefined", - "method-hidden", + "possibly-used-before-assignment", + "no-member", ] [tool.pylint.miscellaneous] -notes = ["FIXME", "TODO", "DEBUG", "WIP"] - -[tool.pylint.typecheck] -mixin-class-rgx = """.*[Mm]ixin|\ - ^(Hilite|InitErrors|DummyWIF|\ - cfg_file|cfg_file_sample|\ - MoneroMMGenFile|keygen_base|xmr_signable|\ - CmdTestShared|CmdTestSwapMethods|HTTPD|\ - RPC|TxProxyClient|Contract)$""" - -ignored-classes = [ # ignored for no-member, otherwise checked - "argparse.Namespace", - "optparse.Values", - "thread._local", - "_thread._local", -# mmgen: - "baseconv", - "deserialized_tx", - "mmgen.autosign.Signable.base", - "mmgen.autosign.Autosign", # tx_dir, etc. created dynamically - "mmgen.rpc.local.RPCClient", - "mmgen.proto.eth.tx.transaction.Transaction", - "mmgen.proto.eth.tw.view.EthereumTwView", - "mmgen.xmrwallet.file.MoneroMMGenTX.Base", - "mmgen.xmrwallet.file.MoneroWalletOutputsFile.Base", - "mmgen.xmrwallet.ops.sweep.OpSweep", - "mmgen.xmrwallet.ops.wallet.OpWallet", - "mmgen.xmrwallet.ops.label.OpLabel", - "mmgen.xmrwallet.ops.new.OpNew", - "mmgen.xmrwallet.ops.txview.OpTxview", - "mmgen.xmrwallet.file.outputs.MoneroWalletOutputsFile.Base", - "mmgen.xmrwallet.file.tx.MoneroMMGenTX.Base", - "MMGenObjectDevTools", - "MnemonicEntry", - "MnEntryMode", - "Sha2", - "TwRPC", - "TxInfo", -# test suite: - "CmdGroupMgr", - "CmdTestEthBumpMethods", - "CmdTestEthdevMethods", - "CmdTestEthSwapMethods", - "FFI_override", - "GenTool", - "Help", - "Opts", - "SwapMgrBase", - "TestHashFunc", - "VirtBlockDeviceBase", -] +notes = ["FIXME", "TODO", "DEBUG", "WIP", "NB"] diff --git a/test/cmdtest_d/autosign.py b/test/cmdtest_d/autosign.py index b8aeec68..052f0eca 100755 --- a/test/cmdtest_d/autosign.py +++ b/test/cmdtest_d/autosign.py @@ -29,7 +29,7 @@ from mmgen.color import red, blue, cyan, orange, purple, gray from mmgen.util import msg, suf, die, indent, fmt from mmgen.led import LEDControl from mmgen.autosign import Autosign -from mmgen.autosign.signable import Signable +from mmgen.autosign.signable import Signable # pylint: disable=no-name-in-module,import-error from ..include.common import ( omsg, diff --git a/test/cmdtest_d/httpd/thornode/rpc.py b/test/cmdtest_d/httpd/thornode/rpc.py index 644617e7..83f6794a 100755 --- a/test/cmdtest_d/httpd/thornode/rpc.py +++ b/test/cmdtest_d/httpd/thornode/rpc.py @@ -34,7 +34,7 @@ class ThornodeRPCServer(ThornodeServer): def get_account_info(m, length): return { 'value': { - 'address': m[1], + 'address': m[1], # pylint: disable=unsubscriptable-object 'pub_key': 'PubKeySecp256k1{0000}', 'account_number': '1234', 'sequence': '333444'}} diff --git a/test/cmdtest_d/include/runner.py b/test/cmdtest_d/include/runner.py index e572ca99..eb34c2d8 100755 --- a/test/cmdtest_d/include/runner.py +++ b/test/cmdtest_d/include/runner.py @@ -120,7 +120,7 @@ class CmdTestRunner: 'PYTHONTRACEMALLOC': '10'}) if self.cfg.exact_output: - from mmgen.term import get_terminal_size + from mmgen.term import get_terminal_size # pylint: disable=no-name-in-module self.spawn_env['MMGEN_COLUMNS'] = str(get_terminal_size().width) else: self.spawn_env['MMGEN_COLUMNS'] = '120' diff --git a/test/cmdtest_d/regtest.py b/test/cmdtest_d/regtest.py index 86dc76fc..087fe1e0 100755 --- a/test/cmdtest_d/regtest.py +++ b/test/cmdtest_d/regtest.py @@ -486,12 +486,12 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): if trunner is None: return - if self.proto.testnet: + if self.proto.testnet: # pylint: disable=access-member-before-definition die(2, '--testnet and --regtest options incompatible with regtest test suite') coin = self.coin - self.proto = init_proto(cfg, coin, network='regtest', need_amt=True) + self.proto = init_proto(cfg, coin, network='regtest', need_amt=True) # redefinition gldict = globals() for k, v in rt_data.items(): diff --git a/test/gentest.py b/test/gentest.py index acda09bb..3f008e4d 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -495,7 +495,7 @@ def parse_args(): match cfg._args: case (gen1, rounds) if is_int(gen1) and is_int(rounds): test, dumpfile = ('speed', None) - case (gen1, dumpfile) if is_int(gen1) and os.access(dumpfile, os.R_OK): + case (gen1, dumpfile) if is_int(gen1) and os.access(dumpfile, os.R_OK): # pylint: disable=used-before-assignment test, rounds = ('dump', None) case (ab, rounds) if (ab := ab.split(':')) and is_int(rounds): test, dumpfile = ('ab', None) diff --git a/test/modtest_d/tx.py b/test/modtest_d/tx.py index b2b7cbf1..0ee2e300 100755 --- a/test/modtest_d/tx.py +++ b/test/modtest_d/tx.py @@ -102,9 +102,9 @@ class unit_tests: def errors(self, name, ut, desc='reading transaction files (error handling)'): async def bad1(): - await CompletedTX(cfg, filename='foo') + await CompletedTX(cfg, filename='foo') # pylint: disable=too-many-function-args def bad2(): - UnsignedTX(cfg, filename='foo') + UnsignedTX(cfg, filename='foo') # pylint: disable=too-many-function-args bad_data = ( ('forbidden positional args', 'TypeError', 'positional arguments', bad1), ('forbidden positional args', 'TypeError', 'positional arguments', bad2),