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

+8 -8
View File
@@ -12,7 +12,7 @@ from unittest import mock
SCRIPTS = pathlib.Path(__file__).resolve().parents[2] / "scripts"
sys.path.insert(0, str(SCRIPTS))
import check_bot_pr_diff as cbd # noqa: E402
import check_bot_pr_diff as cbd
D1, D2 = "sha256:" + "a" * 64, "sha256:" + "b" * 64
FILES = {
@@ -282,7 +282,7 @@ class RepoTest(unittest.TestCase):
"requirements-dev.txt", "# pins\nansible-core==2.19.14\nreuse==6.3.0\n\0"
)
self.commit("bot")
code, unused, err = self.gate()
code, _unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn("requirements-dev.txt", err)
@@ -292,7 +292,7 @@ class RepoTest(unittest.TestCase):
)
(self.repo / "requirements-dev.txt").write_bytes(text.encode("utf-16"))
self.commit("bot")
code, unused, err = self.gate()
code, _unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertEqual(len(err.strip().splitlines()), 1, err)
@@ -300,7 +300,7 @@ class RepoTest(unittest.TestCase):
self.write(".gitattributes", "requirements-dev.txt -diff\n")
self.edit("requirements-dev.txt", "reuse==6.2.0", "reuse==6.3.0")
self.commit("bot")
code, unused, err = self.gate()
code, _unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn(".gitattributes", err)
@@ -374,7 +374,7 @@ class RepoTest(unittest.TestCase):
def test_lowering_a_matrix_version_fails_and_raising_it_passes(self):
self.edit(".gitea/workflows/image.yml", "version: 0.2.0", "version: 0.1.9")
self.commit("lower")
code, unused, err = self.gate()
code, _unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn("version", err)
run(self.repo, "git", "checkout", "-q", "main")
@@ -399,7 +399,7 @@ class RepoTest(unittest.TestCase):
self.write("roles/x/main.yml", "a\n")
self.edit("renovate.json", "{}", '{"a":1}')
self.commit("bot")
code, unused, err = self.gate()
code, _unused, err = self.gate()
self.assertEqual(code, 1)
lines = err.strip().splitlines()
self.assertEqual(len(lines), 3, err)
@@ -418,12 +418,12 @@ class RepoTest(unittest.TestCase):
def test_other_branches_are_skipped(self):
self.write("roles/x/main.yml", "a\n")
self.commit("human")
code, out, unused = self.gate(head="feat/x")
code, out, _unused = self.gate(head="feat/x")
self.assertEqual(code, 0)
self.assertIn("skipped", out)
def test_bad_input(self):
code, unused, err = self.gate(base="--output=x")
code, _unused, err = self.gate(base="--output=x")
self.assertEqual(code, 1)
self.assertNotIn("Traceback", err)
self.assertEqual(