fix(scripts): name the unused tuple members instead of using _
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 14s
Molecule / molecule (pull_request) Successful in 32s

ansible-test sanity's pylint disallows _ as a name (18 findings in the bot-diff gate, the bump script and their tests, build run 2423).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-26 06:54:55 +00:00
1 parent b7b14b7277
commit d6837217c0
3 files changed
+14 -14

No files matched your search

+4 -4
View File
@@ -163,15 +163,15 @@ def parse_numbered(text):
def parse_patch(text):
"""(removed lines, added lines) of a -U0 patch, without the +/- marker."""
removed, added = parse_numbered(text)
return [line for _, line in removed], [line for _, line in added]
return [line for unused, line in removed], [line for unused, line in added]
def version_problem(removed, added):
"""A reason when the matrix `version:` lines were moved, lowered or swapped, else None.
Both lists are (line number, line); the changed lines must sit at the same line numbers."""
if [n for n, _ in removed] != [n for n, _ in added]:
if [n for n, unused in removed] != [n for n, unused in added]:
return "moves or deletes a line (the changed lines must stay where they are)"
for (_, old), (_, new) in zip(removed, added):
for (unused, old), (unused, new) in zip(removed, added):
old_m, new_m = VERSION_LINE.match(old), VERSION_LINE.match(new)
if old_m and new_m and civ.parse_version(new_m["v"]) <= civ.parse_version(old_m["v"]):
return f"does not raise a version ({old_m['v']} -> {new_m['v']})"
@@ -194,7 +194,7 @@ def check(entries, patch_of):
problems.append(f"{path}: a pin change removes and adds at least one line; this diff has "
f"{len(removed)} removed and {len(added)} added (binary or empty change?)")
continue
reason = file_problem(path, [line for _, line in removed], [line for _, line in added])
reason = file_problem(path, [line for unused, line in removed], [line for unused, line in added])
if not reason and path == civ.MATRIX_FILE:
reason = version_problem(removed, added)
if reason:
+3 -3
View File
@@ -129,7 +129,7 @@ class RepoTest(unittest.TestCase):
return (self.repo / ".gitea/workflows/image.yml").read_text()
def test_nothing_changed(self):
code, out, _ = 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"))
@@ -173,7 +173,7 @@ class RepoTest(unittest.TestCase):
def test_bad_base_ref_is_a_clean_failure(self):
for ref in ("--output=x", "nope"):
code, _, 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)
@@ -191,7 +191,7 @@ class RepoTest(unittest.TestCase):
self.write(".gitea/workflows/image.yml", flow)
self.commit("flow")
self.write("requirements-dev.txt", "a==2\n")
code, _, 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)
+7 -7
View File
@@ -149,7 +149,7 @@ class RepoTest(unittest.TestCase):
def test_a_nul_containing_file_is_refused(self):
self.write("requirements-dev.txt", "# pins\nansible-core==2.19.14\nreuse==6.3.0\n\0")
self.commit("bot")
code, _, err = self.gate()
code, unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn("requirements-dev.txt", err)
@@ -157,7 +157,7 @@ class RepoTest(unittest.TestCase):
text = (self.repo / "requirements-dev.txt").read_text().replace("6.2.0", "6.3.0")
(self.repo / "requirements-dev.txt").write_bytes(text.encode("utf-16"))
self.commit("bot")
code, _, err = self.gate()
code, unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertEqual(len(err.strip().splitlines()), 1, err)
@@ -165,7 +165,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, _, err = self.gate()
code, unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn(".gitattributes", err)
@@ -214,7 +214,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, _, err = self.gate()
code, unused, err = self.gate()
self.assertEqual(code, 1, err)
self.assertIn("version", err)
run(self.repo, "git", "checkout", "-q", "main")
@@ -239,7 +239,7 @@ class RepoTest(unittest.TestCase):
self.write("roles/x/main.yml", "a\n")
self.edit("renovate.json", "{}", '{"a":1}')
self.commit("bot")
code, _, err = self.gate()
code, unused, err = self.gate()
self.assertEqual(code, 1)
lines = err.strip().splitlines()
self.assertEqual(len(lines), 3, err)
@@ -258,12 +258,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, _ = 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, _, err = self.gate(base="--output=x")
code, unused, err = self.gate(base="--output=x")
self.assertEqual(code, 1)
self.assertNotIn("Traceback", err)
self.assertEqual(subprocess.run([sys.executable, str(SCRIPTS / "check_bot_pr_diff.py")], cwd=self.repo,