chore: lint scripts and tests with ruff

pyproject.toml now carries the ruff rule set: pyflakes, the B rules,
simplify, perf, pyupgrade, complexity and size limits. This commit
applies the fixes that change no behavior and the small defects the
first run named:

- tests/test_install.py used argparse without importing it
- three loops rebound the outer `profile` with each layout
  (packextras, slots, verify); the loop variable is now `layout`
- profile_sync loops shadowed dataclasses.field
- generate_readme and packextras computed values nothing read
- stale noqa markers for rules the project does not enforce

Complexity, size and the remaining findings are handled next.
This commit is contained in:
Abdessamad Derraz committed 2026-11-17 07:07:48 +01:00
1 parent 9d8dcb1634
commit 4eacb6ff39
186 files changed
+1001 -1058

No files matched your search

+6 -6
View File
@@ -180,7 +180,7 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
def test_threads_reading_the_mode_leave_the_umask_alone(self):
"""mame_devices fetches on eight threads and every cache write reads
the umask: unguarded, two readers interleaved and left it at 0."""
import threading # noqa: PLC0415
import threading
interval = sys.getswitchinterval()
sys.setswitchinterval(1e-6)
@@ -210,9 +210,9 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
self.assertEqual(offenders, [])
def test_packs_and_their_manifest(self):
import zipfile # noqa: PLC0415
import zipfile
import generate_pack # noqa: PLC0415
import generate_pack
pack = self.dir / "Pack.zip"
with generate_pack._writing_pack(str(pack)) as zf:
@@ -230,7 +230,7 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
copy_file_atomic is the one exception: copy2 gives the scratch the
source file's own mode.
"""
import ast # noqa: PLC0415
import ast
def name_of(node: ast.AST) -> str | None:
return node.id if isinstance(node, ast.Name) else None
@@ -317,8 +317,8 @@ class ATerminatedBuildLeavesNoScratch(unittest.TestCase):
)
def test_sigterm_removes_the_partial_pack(self):
import signal # noqa: PLC0415
import subprocess # noqa: PLC0415
import signal
import subprocess
if not hasattr(signal, "SIGTERM") or os.name != "posix":
self.skipTest("POSIX signals")