diff --git a/Makefile b/Makefile index 83b1464d7a..34f3ed11bf 100644 --- a/Makefile +++ b/Makefile @@ -1565,8 +1565,8 @@ cpplint: lint-cpp # Try with '--system' if it fails without; the system may have set '--user' lint-py-build: ## Build resources needed to lint python files. $(info Pip installing ruff on $(shell $(PYTHON) --version)...) - $(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff==0.6.5 || \ - $(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff==0.6.5 + $(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff==0.13.1 || \ + $(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff==0.13.1 .PHONY: lint-py lint-py-fix lint-py-fix-unsafe ifneq ("","$(wildcard tools/pip/site-packages/ruff)") @@ -1576,7 +1576,6 @@ lint-py: tools/pip/site-packages/bin/ruff check . lint-py-fix: tools/pip/site-packages/bin/ruff check . --fix - lint-py-fix-unsafe: tools/pip/site-packages/bin/ruff check . --fix --unsafe-fixes else diff --git a/configure.py b/configure.py index 751db8a19e..5a05a1fdcd 100755 --- a/configure.py +++ b/configure.py @@ -1300,7 +1300,7 @@ def check_compiler(o): print_verbose(f"Detected {'Apple ' if is_apple else ''}{'clang ' if is_clang else ''}C++ compiler (CXX={CXX}) version: {version_str}") if not ok: warn(f'failed to autodetect C++ compiler version (CXX={CXX})') - elif (is_apple and clang_version < (17, 0, 0) or not is_apple and clang_version < (19, 1, 0)) if is_clang else gcc_version < (12, 2, 0): + elif ((is_apple and clang_version < (17, 0, 0)) or (not is_apple and clang_version < (19, 1, 0))) if is_clang else gcc_version < (12, 2, 0): warn(f"C++ compiler (CXX={CXX}, {version_str}) too old, need g++ 12.2.0 or clang++ 19.1.0{' or Apple clang++ 17.0.0' if is_apple else ''}") ok, is_clang, clang_version, gcc_version, is_apple = try_check_compiler(CC, 'c') diff --git a/pyproject.toml b/pyproject.toml index 43da73bece..196e9dca7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,11 +11,13 @@ target-version = "py39" [tool.ruff.lint] select = [ + "ASYNC", # flake8-async "C90", # McCabe cyclomatic complexity "E", # pycodestyle "F", # Pyflakes "ICN", # flake8-import-conventions "INT", # flake8-gettext + "PERF", # flake8-performance "PLC", # Pylint conventions "PLE", # Pylint errors "PLR09", # Pylint refactoring: max-args, max-branches, max returns, max-statements @@ -32,6 +34,7 @@ ignore = [ "E401", "E402", "E7", + "PLC0415", "RUF005", ] diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 05d2460f92..605f2d2daa 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -160,9 +160,7 @@ class AddonTestConfiguration(SimpleTestConfiguration): result = [] for subpath in os.listdir(path): if os.path.isdir(os.path.join(path, subpath)): - for f in os.listdir(os.path.join(path, subpath)): - if SelectTest(f): - result.append([subpath, f[:-3]]) + result.extend([subpath, f[:-3]] for f in os.listdir(os.path.join(path, subpath)) if SelectTest(f)) return result def ListTests(self, current_path, path, arch, mode): diff --git a/test/tools/test_checkimports.py b/test/tools/test_checkimports.py index 6e8e17cc3f..fd28542e45 100644 --- a/test/tools/test_checkimports.py +++ b/test/tools/test_checkimports.py @@ -28,7 +28,7 @@ class CheckImportsTest(unittest.TestCase): 'test', 'fixtures', 'tools', 'checkimports') def test_unused_and_unsorted(self): - with captured_output() as (out, err): + with captured_output() as (out, _err): self.assertEqual(is_valid(path.join(self.fixturesDir, 'invalid.cc')), False) output = out.getvalue() @@ -42,21 +42,21 @@ class CheckImportsTest(unittest.TestCase): output); def test_unused_complex(self): - with captured_output() as (out, err): + with captured_output() as (out, _err): self.assertEqual(is_valid(path.join(self.fixturesDir, 'maybe.cc')), False) output = out.getvalue() self.assertIn('does not use "Local"', output); def test_unused_simple(self): - with captured_output() as (out, err): + with captured_output() as (out, _err): self.assertEqual(is_valid(path.join(self.fixturesDir, 'unused.cc')), False) output = out.getvalue() self.assertIn('does not use "Context"', output); def test_unsorted(self): - with captured_output() as (out, err): + with captured_output() as (out, _err): self.assertEqual(is_valid(path.join(self.fixturesDir, 'unsorted.cc')), False) output = out.getvalue() @@ -67,7 +67,7 @@ class CheckImportsTest(unittest.TestCase): output); def test_valid(self): - with captured_output() as (out, err): + with captured_output() as (out, _err): self.assertEqual(is_valid(path.join(self.fixturesDir, 'valid.cc')), True) output = out.getvalue() diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py index ac8edb6896..abd11e1dbd 100755 --- a/tools/generate_config_gypi.py +++ b/tools/generate_config_gypi.py @@ -95,7 +95,7 @@ def main(): default='//node') parser.add_argument('--dep-file', help='path to an optional dep file', default=None) - args, unknown_args = parser.parse_known_args() + args, _unknown_args = parser.parse_known_args() config = get_gn_config(args.out_dir) v8_config = get_v8_config(args.out_dir, args.node_gn_path) diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py index 0ae8c23319..4441550df0 100755 --- a/tools/icu/icutrim.py +++ b/tools/icu/icutrim.py @@ -339,17 +339,17 @@ def removeList(count=0): removeList(1) # now, fixup res_index, one at a time -for tree in trees: +for tree, value in trees.items(): # skip trees that don't have res_index - if "hasIndex" not in trees[tree]: + if "hasIndex" not in value: continue treebunddir = options.tmpdir - if(trees[tree]["treeprefix"]): - treebunddir = os.path.join(treebunddir, trees[tree]["treeprefix"]) + if(value["treeprefix"]): + treebunddir = os.path.join(treebunddir, value["treeprefix"]) if not (os.path.isdir(treebunddir)): os.mkdir(treebunddir) treebundres = os.path.join(treebunddir,RES_INDX) treebundtxt = "%s.txt" % (treebundres[0:-4]) runcmd("iculslocs", "-i %s -N %s -T %s -b %s" % (outfile, dataname, tree, treebundtxt)) runcmd("genrb","-d %s -s %s res_index.txt" % (treebunddir, treebunddir)) - runcmd("icupkg","-s %s -a %s%s %s" % (options.tmpdir, trees[tree]["treeprefix"], RES_INDX, outfile)) + runcmd("icupkg","-s %s -a %s%s %s" % (options.tmpdir, value["treeprefix"], RES_INDX, outfile)) diff --git a/tools/install.py b/tools/install.py index 24c297d60a..573d7423c9 100755 --- a/tools/install.py +++ b/tools/install.py @@ -73,7 +73,7 @@ def try_copy(options, path, dest): return shutil.copy2(source_path, target_path) def try_remove(options, path, dest): - source_path, target_path = mkpaths(options, path, dest) + _source_path, target_path = mkpaths(options, path, dest) if not options.silent: print('removing %s' % target_path) try_unlink(target_path) diff --git a/tools/test.py b/tools/test.py index da72e761bb..8457bbd939 100755 --- a/tools/test.py +++ b/tools/test.py @@ -817,7 +817,7 @@ def Execute(args, context, timeout=None, env=None, disable_core_files=False, else: preexec_fn = setMaxVirtualMemory - (process, exit_code, timed_out) = RunProcess( + (_process, exit_code, timed_out) = RunProcess( context, timeout, args = args, @@ -924,7 +924,7 @@ class LiteralTestSuite(TestSuite): return result def ListTests(self, current_path, path, context, arch, mode): - (name, rest) = CarCdr(path) + (name, _rest) = CarCdr(path) result = [ ] for test in self.tests_repos: test_name = test.GetName()