fix(codescan): clear the mechanical CodeQL notes and lint them away (WIP)

Work-in-progress commit on the collective code-scanning sidetree, so main
can be merged in; the single quality-high gate runs on the integration
branch before the pull request.

Fixes the CodeQL notes py/import-and-import-from, py/unused-import,
py/unused-global-variable, py/empty-except, py/mixed-tuple-returns and
py/unused-local-variable across 194 files, and adds one lint per rule under
tests/lint/repository/python/ so none of them can come back:
test_import_and_import_from, test_unused_imports_hidden_from_ruff,
test_unused_global_variables, test_empty_except, test_mixed_tuple_returns,
test_unused_local_variables, plus test_modules_import.

Accepted security finding: MEDUSA-MP-SCAN-2056 (low) on
utils/i18n/client.py:21, an import line matched by a keyword heuristic;
operator-confirmed false positive.

🎯 Fix: 85 %
💥 Break: 8 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 78
🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-11-13 18:44:29 +00:00
1 parent 3fdfce419e
commit 326f063bd3
194 files changed
+1663 -590

No files matched your search

@@ -4,9 +4,9 @@ import io
import json
import tempfile
import unittest
import unittest.mock
from contextlib import redirect_stderr, redirect_stdout
from pathlib import Path
from unittest import mock
from cli.meta.ci.variant_split import __main__ as cli
from cli.meta.ci.variant_split import snapshot as snapshot_module
@@ -95,7 +95,7 @@ class TestMain(unittest.TestCase):
def test_snapshot_passes_the_seed_and_records_it(self) -> None:
out_path = self.tmp / "snap.json"
with mock.patch.object(
with unittest.mock.patch.object(
snapshot_module, "take", return_value=_snap(seed="42")
) as take:
rc, _, _ = self._run(
@@ -2,8 +2,8 @@ from __future__ import annotations
import tempfile
import unittest
import unittest.mock
from pathlib import Path
from unittest import mock
from cli.meta.ci.variant_split import rounds
from utils.roles.mapping import ROLE_FILE_META_SERVICES, ROLE_FILE_META_VARIANTS
@@ -92,7 +92,9 @@ class TestDictated(unittest.TestCase):
def _dictated(self, include: list[str], active: dict[str, int]) -> dict:
found = {("web-app-a", 1): {"web-app-b", "web-app-gone"}}
with mock.patch.object(rounds, "overridden_providers", return_value=found):
with unittest.mock.patch.object(
rounds, "overridden_providers", return_value=found
):
return rounds.dictated(include, active, roles_dir="/roles")
def test_a_member_whose_config_a_variant_dictates_names_that_variant(
@@ -3,8 +3,8 @@ from __future__ import annotations
import os
import tempfile
import unittest
import unittest.mock
from pathlib import Path
from unittest import mock
from cli.meta.ci.variant_split import snapshot
from utils.roles.mapping import ROLE_FILE_META_VARIANTS
@@ -83,7 +83,7 @@ class TestSeeds(unittest.TestCase):
def test_an_empty_seed_never_takes_a_snapshot(self) -> None:
with (
mock.patch.object(snapshot, "pipeline") as pipeline,
unittest.mock.patch.object(snapshot, "pipeline") as pipeline,
self.assertRaises(ValueError),
):
snapshot.take([0], seed=" ")
@@ -97,8 +97,8 @@ class TestSeeds(unittest.TestCase):
raise RuntimeError
with (
mock.patch.dict(os.environ, {}),
mock.patch.object(snapshot, "pipeline", pipeline),
unittest.mock.patch.dict(os.environ, {}),
unittest.mock.patch.object(snapshot, "pipeline", pipeline),
self.assertRaises(RuntimeError),
):
snapshot.take([0], seed="42305502796")
@@ -3,8 +3,8 @@ from __future__ import annotations
import io
import json
import unittest
import unittest.mock
from contextlib import redirect_stderr, redirect_stdout
from unittest import mock
from cli.meta.ci.variant_tree import __main__ as cli
from cli.meta.ci.variant_tree import tree
@@ -32,12 +32,14 @@ AXES = {"0": {"entries": [], "job_position": 3, "in_budget_head": True, "covered
class TestMain(unittest.TestCase):
def _run(
self, *argv: str, built: dict | None = None
) -> tuple[int, str, str, mock.Mock]:
) -> tuple[int, str, str, unittest.mock.Mock]:
out, err = io.StringIO(), io.StringIO()
with (
mock.patch("utils.cache.applications.get_variants", return_value=FOUR),
mock.patch.object(tree, "build", wraps=tree.build) as build,
mock.patch(
unittest.mock.patch(
"utils.cache.applications.get_variants", return_value=FOUR
),
unittest.mock.patch.object(tree, "build", wraps=tree.build) as build,
unittest.mock.patch(
"cli.meta.ci.variant_split.snapshot.row_axes", return_value=AXES
) as axes,
redirect_stdout(out),