From cb5d22b25fce4aee3c2acedea7b3b36e1e0fd4c5 Mon Sep 17 00:00:00 2001 From: didericis Date: Sat, 11 Jul 2026 19:21:04 -0400 Subject: [PATCH] fix(tests): satisfy pyright strict on the overlap-test helper The TestNetpoolOverlap `_routes` helper had an untyped fake_run + a bare `dict`/`object` return, tripping 9 strict-mode errors (missing type args, missing param annotations, `object` not usable as a context manager). Type it properly: entries: list[dict[str, str]], fake_run params, and a `AbstractContextManager[MagicMock]` return. `pyright` is clean again. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck --- tests/unit/test_firecracker_backend.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_firecracker_backend.py b/tests/unit/test_firecracker_backend.py index 4e3d5a9..d06a85e 100644 --- a/tests/unit/test_firecracker_backend.py +++ b/tests/unit/test_firecracker_backend.py @@ -8,11 +8,14 @@ the VM boot-arg assembly. from __future__ import annotations import base64 +import json import os +import subprocess import unittest +from contextlib import AbstractContextManager from pathlib import Path from typing import Any, cast -from unittest.mock import patch +from unittest.mock import MagicMock, patch from bot_bottle.backend.firecracker import firecracker_vm, netpool from bot_bottle.backend.firecracker.bottle import FirecrackerBottle @@ -137,11 +140,12 @@ class TestNetpoolOverlap(unittest.TestCase): existing host route (Tailscale CGNAT peer, docker/libvirt bridge, LAN) and ignores our own bbfc TAPs + the default route.""" - def _routes(self, entries: list[dict]) -> object: - import json - import subprocess - - def fake_run(argv, **kwargs): + def _routes( + self, entries: list[dict[str, str]] + ) -> AbstractContextManager[MagicMock]: + def fake_run( + argv: list[str], **kwargs: object + ) -> subprocess.CompletedProcess[str]: return subprocess.CompletedProcess( argv, 0, stdout=json.dumps(entries), stderr="", )