From 783b05e37343a256449e0ff27cb66eabc98bab7b Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 3 Jan 2025 14:23:14 +0000 Subject: [PATCH] migrate from Pylint to Ruff Testing: $ test/test-release.sh -v lint --- README.md | 2 +- mmgen/cfg.py | 1 - mmgen/fileutil.py | 7 +++---- mmgen/xmrwallet/ops/__init__.py | 7 ------- scripts/mmgen-wallet-nix/packages.nix | 2 +- test-requirements.txt | 2 -- test/cmdtest_d/ct_automount.py | 1 - test/cmdtest_d/ct_regtest.py | 3 +-- test/modtest_d/ut_testdep.py | 8 -------- test/test-release.d/cfg.sh | 14 ++++---------- test/test-release.sh | 4 +--- 11 files changed, 11 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index facd0fce..04203b8b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ##### An online/offline cryptocurrency wallet for the command line ![build](https://github.com/mmgen/mmgen-wallet/workflows/build/badge.svg) -![pylint](https://github.com/mmgen/mmgen-wallet/workflows/pylint/badge.svg) +![ruff](https://github.com/mmgen/mmgen-wallet/workflows/ruff/badge.svg) ### Description diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 3fe5bb51..53e763cf 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -106,7 +106,6 @@ class GlobalConstants(Lockable): # https://importlib-resources.readthedocs.io/en/latest/migration.html # https://setuptools.readthedocs.io/en/latest/pkg_resources.html - # TODO: remove try..except (workaround for Python 3.9 pylint bug) try: from importlib.resources import files # Python 3.9 and above except ImportError: diff --git a/mmgen/fileutil.py b/mmgen/fileutil.py index af456be1..7cbcf2e3 100755 --- a/mmgen/fileutil.py +++ b/mmgen/fileutil.py @@ -210,10 +210,9 @@ def write_data_to_file( else: msg('Redirecting output to file') - if binary: - if sys.platform == 'win32': # condition on separate line for pylint - import msvcrt - msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) + if binary and sys.platform == 'win32': + import msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) # MSWin workaround. See msg_r() try: diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index 046cc1cf..1f5990ae 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -23,13 +23,6 @@ from ... import xmrwallet from .. import uarg_info -# required to squelch pylint: -def fmt_amt(amt): - return str(amt) - -def hl_amt(amt): - return str(amt) - class OpBase: opts = ('wallet_dir',) diff --git a/scripts/mmgen-wallet-nix/packages.nix b/scripts/mmgen-wallet-nix/packages.nix index 437d43e7..130b0cdb 100644 --- a/scripts/mmgen-wallet-nix/packages.nix +++ b/scripts/mmgen-wallet-nix/packages.nix @@ -70,7 +70,6 @@ let # pysocks # XMR pexpect # test suite pycoin # test suite - pylint # test suite (requires ==3.1.1) # monero # XMR (test suite) # eth-keys # ETH, ETC (test suite) ]); @@ -103,6 +102,7 @@ in secp256k1 = pkgs.secp256k1; less = pkgs.less; # test suite (cmdtest.py regtest) procps = pkgs.procps; # test suite (pgrep) + ruff = pkgs.ruff; ## For development with --pure (add/remove packages for your setup): neovim-qt = pkgs.neovim-qt; diff --git a/test-requirements.txt b/test-requirements.txt index 5da46efd..4bd65b91 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,3 @@ pycoin monero eth_keys -pylint==3.1.1 -# pylint 3.2.0 fails with import errors for mmgen.term and mmgen.proto.secp256k1.secp256k1 diff --git a/test/cmdtest_d/ct_automount.py b/test/cmdtest_d/ct_automount.py index 00313e53..f4741ed7 100755 --- a/test/cmdtest_d/ct_automount.py +++ b/test/cmdtest_d/ct_automount.py @@ -23,7 +23,6 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtestBDBWallet) networks = ('btc', 'bch', 'ltc') tmpdir_nums = [49] - rtFundAmt = None # pylint rt_data = { 'rtFundAmt': {'btc':'500', 'bch':'500', 'ltc':'5500'}, } diff --git a/test/cmdtest_d/ct_regtest.py b/test/cmdtest_d/ct_regtest.py index 15ef5644..338d9150 100755 --- a/test/cmdtest_d/ct_regtest.py +++ b/test/cmdtest_d/ct_regtest.py @@ -63,7 +63,7 @@ pat_date_time = r'\b\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d\b' dfl_wcls = get_wallet_cls('mmgen') -tx_fee = rtFundAmt = rtFee = rtBals = rtBals_gb = rtBobOp3 = rtAmts = {} # pylint +tx_fee = rtFundAmt = rtFee = rtBals = rtBals_gb = rtBobOp3 = rtAmts = {} # ruff rt_pw = 'abc-α' rt_data = { 'tx_fee': {'btc':'0.0001', 'bch':'0.001', 'ltc':'0.01'}, @@ -176,7 +176,6 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared): color = True deterministic = False test_rbf = False - proto = None # pylint bdb_wallet = False cmd_group_in = ( diff --git a/test/modtest_d/ut_testdep.py b/test/modtest_d/ut_testdep.py index cbd335d0..86243ead 100755 --- a/test/modtest_d/ut_testdep.py +++ b/test/modtest_d/ut_testdep.py @@ -37,14 +37,6 @@ class unit_tests: raise return True - def pylint(self, name, ut): - try: - return run(['pylint', '--version'], stdout=None if cfg.verbose else DEVNULL).returncode == 0 - except OSError as e: - ymsg(' ' + str(e)) - bmsg(" Install pylint with 'python3 -m pip install pylint'") - return False - def pycoin(self, name, ut): from pycoin.networks.registry import network_for_netcode as nfnc network = nfnc('btc') diff --git a/test/test-release.d/cfg.sh b/test/test-release.d/cfg.sh index 5564e986..8f631ec8 100755 --- a/test/test-release.d/cfg.sh +++ b/test/test-release.d/cfg.sh @@ -71,20 +71,14 @@ init_tests() { - $cmdtest_py dev " - PYLINT_OPTS='--errors-only --jobs=0' + [ "$VERBOSE" ] || STDOUT_DEVNULL='> /dev/null' d_lint="code errors with static code analyzer" t_lint=" - b $pylint $PYLINT_OPTS mmgen - b $pylint $PYLINT_OPTS test - b $pylint $PYLINT_OPTS --disable=relative-beyond-top-level test/cmdtest_d - a $pylint $PYLINT_OPTS --ignore-paths '.*/eth/.*' mmgen - a $pylint $PYLINT_OPTS --ignore-paths '.*/ut_dep.py,.*/ut_testdep.py' test - a $pylint $PYLINT_OPTS --ignore-paths '.*/ct_ethdev.py' --disable=relative-beyond-top-level test/cmdtest_d - - $pylint $PYLINT_OPTS examples + b ruff check mmgen $STDOUT_DEVNULL + b ruff check test $STDOUT_DEVNULL + b ruff check examples $STDOUT_DEVNULL " - if [ "$SKIP_ALT_DEP" ]; then t_lint_skip='b'; else t_lint_skip='a'; fi - d_daemon="low-level subsystems involving coin daemons" t_daemon="- $daemontest_py --exclude exec" diff --git a/test/test-release.sh b/test/test-release.sh index fb1a658d..2d76cfe8 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -278,7 +278,6 @@ gentest_py='test/gentest.py --quiet' scrambletest_py='test/scrambletest.py' altcoin_mod_opts='--quiet' mmgen_tool='cmds/mmgen-tool' -pylint='PYTHONPATH=. pylint' # PYTHONPATH required by older Pythons (e.g. v3.9) python='python3' rounds=10 typescript_file='test-release.out' @@ -373,8 +372,7 @@ do tooltest_py+=" --verbose" mmgen_tool+=" --verbose" objattrtest_py+=" --verbose" - scrambletest_py+=" --verbose" - pylint+=" --verbose" ;; + scrambletest_py+=" --verbose" ;; X) IN_REEXEC=1 ;; *) exit ;; esac