fix(scripts): resolve the ruff findings in the scripts and tests

Fix what ruff 0.17.5's default rule set and the complexity rules report (#112):
removeprefix/removesuffix instead of slicing, `_unused` for discarded tuple
members, obsolete `noqa: E402` removed, a parenthesised string pair and an
immutable class constant in the tests.

Three functions stay over a complexity threshold and carry an inline
`# noqa` with the rule code and a reason: matrix_of and copy_sources of
check_image_versions.py (#96 may replace them) and path_problems of
check_tarball.py. No rule is ignored globally and no threshold is tuned.

ruff writes .ruff_cache/ into the checkout, which test_real_build_passes
caught in the Collection archive: add it to galaxy.yml build_ignore. ruff.toml
joins the molecule selector's IGNORED paths, since no scenario reads it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNmHMc85bomfevwUDG
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-11-14 13:34:05 +00:00
1 parent db1c1e176f
commit 697e4b6092
9 files changed
+30 -26

No files matched your search

+4 -4
View File
@@ -12,7 +12,7 @@ import unittest
SCRIPTS = pathlib.Path(__file__).resolve().parents[2] / "scripts"
sys.path.insert(0, str(SCRIPTS))
import bump_image_versions as biv # noqa: E402
import bump_image_versions as biv
IMAGE_YML = """\
# header comment
@@ -152,7 +152,7 @@ class RepoTest(unittest.TestCase):
return (self.repo / ".gitea/workflows/image.yml").read_text()
def test_nothing_changed(self):
code, out, unused = self.bump()
code, out, _unused = self.bump()
self.assertEqual((code, out), (0, "image versions: nothing to bump\n"))
self.assertEqual(self.versions(), IMAGE_YML.format(mol="0.1.0", ci="0.2.0"))
@@ -200,7 +200,7 @@ class RepoTest(unittest.TestCase):
def test_bad_base_ref_is_a_clean_failure(self):
for ref in ("--output=x", "nope"):
code, unused, err = self.bump(ref)
code, _unused, err = self.bump(ref)
self.assertEqual(code, 1)
self.assertNotIn("Traceback", err)
self.assertEqual(len(err.strip().splitlines()), 1, err)
@@ -225,7 +225,7 @@ class RepoTest(unittest.TestCase):
self.write(".gitea/workflows/image.yml", flow)
self.commit("flow")
self.write("requirements-dev.txt", "a==2\n")
code, unused, err = self.bump()
code, _unused, err = self.bump()
self.assertEqual(code, 1)
self.assertEqual(len(err.strip().splitlines()), 1, err)
self.assertEqual(self.versions(), flow)