From 7f19ff2ceb27179933308f5edfc7722a6d75503c Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:07:21 +0100 Subject: [PATCH] chore: type the test fixtures mypy rejected --- tests/test_audit_regressions.py | 10 ++++++---- tests/test_autorun.py | 2 +- tests/test_layers.py | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 7fe235591..e5c47a7b6 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -2838,7 +2838,7 @@ class ReleaseAssetsMatchTheCollection(unittest.TestCase): from scripts import pipeline - def steps(*flags: str) -> list[str]: + def steps(*flags: str) -> tuple[list[str], str]: ran: list[str] = [] def record(cmd, label): @@ -4249,7 +4249,7 @@ class ACitationInsideASourceRefIsTracked(unittest.TestCase): zesarux cited src/cpu.h:545 inside an annotation, four lines off at its pin, and pce-emu joined two citations with ` + `: neither was anchored.""" - def citations(self, ref: str) -> list[str]: + def citations(self, ref: str) -> list[tuple[str, str]]: from scripts.profiling.citations import collect_citations document = {"files": [{"name": "x.rom", "source_ref": ref}]} @@ -7600,9 +7600,11 @@ class ExternalDownloadsFollowTheRunPolicy(unittest.TestCase): ENTRY = {"name": "ext.bin", "source_url": "https://example.invalid/ext.bin", "sha1": hashlib.sha1(b"payload").hexdigest()} + class _Body(io.BytesIO): + headers: dict = {} + def _response(self, body: bytes): - stream = io.BytesIO(body) - stream.headers = {} + stream = self._Body(body) response = mock.MagicMock() response.__enter__.return_value = stream response.__exit__.return_value = False diff --git a/tests/test_autorun.py b/tests/test_autorun.py index 04cb3a7d3..a51cd5eaf 100644 --- a/tests/test_autorun.py +++ b/tests/test_autorun.py @@ -848,7 +848,7 @@ class BiosIntegrity(Scratch): "bios/Big/large.iso": b"\x99" * 2048, } (self.repo / ".gitignore").write_text("bios/Big/large.iso\n", encoding="utf-8") - self.db = {"files": {}} + self.db: dict[str, dict[str, dict[str, str]]] = {"files": {}} for rel, data in files.items(): path = self.repo / rel path.parent.mkdir(parents=True, exist_ok=True) diff --git a/tests/test_layers.py b/tests/test_layers.py index 9c4e5b1b6..d607f9882 100644 --- a/tests/test_layers.py +++ b/tests/test_layers.py @@ -182,6 +182,8 @@ def find_cycle(nodes: set[str], edges: dict[str, set[str]]) -> list[str] | None: class ImportLayers(unittest.TestCase): + graph: Graph + @classmethod def setUpClass(cls) -> None: cls.graph = Graph()