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

+12 -12
View File
@@ -157,11 +157,11 @@ class ManifestsServeWhatTheCoreAccepts(unittest.TestCase):
Nintendo's dump, which Dolphin's check accepts, sat in .variants/."""
def test_no_served_core_file_fails_its_check_beside_a_passing_variant(self):
import json # noqa: PLC0415
import json
from common import load_emulator_profiles, load_platform_config # noqa: PLC0415
from generate_pack import _platform_cores # noqa: PLC0415
from validation import check_file_validation # noqa: PLC0415
from common import load_emulator_profiles, load_platform_config
from generate_pack import _platform_cores
from validation import check_file_validation
manifest_path = REPO_ROOT / "install" / "retroarch.json"
if not (REPO_ROOT / "database.json").is_file() or not manifest_path.is_file():
@@ -197,7 +197,7 @@ class EachReaderJudgesWithItsOwnRules(unittest.TestCase):
Wii U otp.bin, and the variant search gave Cemu the 3DS file."""
def test_rules_of_another_emulator_do_not_judge(self):
from validation import check_file_validation # noqa: PLC0415
from validation import check_file_validation
index = _build_validation_index({
"azahar": {"files": [{"name": "otp.bin", "path": "sysdata/otp.bin",
@@ -212,7 +212,7 @@ class EachReaderJudgesWithItsOwnRules(unittest.TestCase):
self.assertIsNotNone(check_file_validation(str(wiiu), "otp.bin", index, tmp, {"azahar"}))
def test_one_of_an_emulators_entries_is_enough(self):
from validation import check_file_validation # noqa: PLC0415
from validation import check_file_validation
index = _build_validation_index({"raze": {"files": [
{"name": "SW.GRP", "size": 100, "validation": ["size"]},
@@ -234,8 +234,8 @@ class DolphinForksJudgeTheirOwnDspTable(unittest.TestCase):
FREE_V031 = REPO_ROOT / "bios" / "Nintendo" / "GameCube" / "Sys" / "GC" / "dsp_rom.bin"
def test_each_fork_accepts_its_own_free_rom(self):
from common import load_emulator_profiles # noqa: PLC0415
from validation import check_file_validation # noqa: PLC0415
from common import load_emulator_profiles
from validation import check_file_validation
if not self.FREE_V04.is_file() or not self.FREE_V031.is_file():
self.skipTest("free DSP ROMs not present")
@@ -292,7 +292,7 @@ class AWarningRejectsNothing(unittest.TestCase):
self.assertEqual((chosen, disagreement), (str(good), None))
def test_the_merged_view_rejects_nothing_for_it(self):
from validation import check_file_validation # noqa: PLC0415
from validation import check_file_validation
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
short, _good, _db, index = self._setup(tmp, held_good=False)
@@ -347,7 +347,7 @@ class AVersionTakenWithoutACheck(unittest.TestCase):
return str(path)
def test_the_unchecked_version_accepts_the_copy(self):
from validation import check_file_validation # noqa: PLC0415
from validation import check_file_validation
index = _build_validation_index({"raze": self.RAZE})
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
@@ -356,7 +356,7 @@ class AVersionTakenWithoutACheck(unittest.TestCase):
))
def test_the_pack_reads_it_as_an_alternative(self):
import generate_pack # noqa: PLC0415
import generate_pack
fe = {"name": "BLOOD.RFF", "source_profile": "raze", "source_path": "BLOOD.RFF"}
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
@@ -365,7 +365,7 @@ class AVersionTakenWithoutACheck(unittest.TestCase):
))
def test_a_refusal_names_every_accepted_size(self):
from validation import check_file_validation # noqa: PLC0415
from validation import check_file_validation
checked = {"files": self.RAZE["files"][:2]}
index = _build_validation_index({"raze": checked})