Browse Source

migrate from Pylint to Ruff

Testing:

    $ test/test-release.sh -v lint
The MMGen Project 2 months ago
parent
commit
783b05e373

+ 1 - 1
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
 

+ 0 - 1
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:

+ 3 - 4
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:

+ 0 - 7
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',)

+ 1 - 1
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;

+ 0 - 2
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

+ 0 - 1
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'},
 	}

+ 1 - 2
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 = (

+ 0 - 8
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')

+ 4 - 10
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"
 

+ 1 - 3
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