From dcba9becc9f47b6c82e73911aee538d295ebd615 Mon Sep 17 00:00:00 2001 From: Dom <168790843+firestar5683@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:18:46 -0600 Subject: [PATCH] Type the dynamically loaded bookmark test helper Preserve existing assertions and explicitly narrow the optional checkpoint. Focused ty and Ruff checks and all 29 bookmark tests pass. Refresh receipt for test-only changes; production source and native artifacts remain unchanged. --- openpilot/selfdrive/selfdrived/tests/test_bookmarks.py | 9 ++++++--- prebuilt.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openpilot/selfdrive/selfdrived/tests/test_bookmarks.py b/openpilot/selfdrive/selfdrived/tests/test_bookmarks.py index 80faeb507d..d1d86a6808 100644 --- a/openpilot/selfdrive/selfdrived/tests/test_bookmarks.py +++ b/openpilot/selfdrive/selfdrived/tests/test_bookmarks.py @@ -1,6 +1,8 @@ import ast +from collections.abc import Callable from pathlib import Path from types import SimpleNamespace as NS +from typing import cast from unittest.mock import patch import pytest @@ -15,9 +17,9 @@ source = Path(__file__).parents[1] / 'selfdrived.py' module = ast.parse(source.read_text()) owner = next(node for node in module.body if isinstance(node, ast.ClassDef) and node.name == 'SelfdriveD') method = next(node for node in owner.body if isinstance(node, ast.FunctionDef) and node.name == '_update_bookmarks') -namespace = {'messaging': messaging, 'EventName': EventName} +namespace: dict[str, object] = {'messaging': messaging, 'EventName': EventName} exec(compile(ast.Module(body=[method], type_ignores=[]), str(source), 'exec'), namespace) -update_bookmarks = namespace['_update_bookmarks'] +update_bookmarks = cast(Callable[[NS], None], namespace['_update_bookmarks']) class Sources(dict): @@ -117,7 +119,7 @@ def test_large_burst_is_bounded_without_discarding_remaining_bookmarks(): class SavedCheckpoint: - def __init__(self, value=None): + def __init__(self, value: dict[str, object] | None = None): self.value = value self.writes = self.reads = self.removes = 0 @@ -168,6 +170,7 @@ def test_unseen_startup_device_state_does_not_erase_saved_count(): sources.seen = {'deviceState': False} drive = NS(bookmarks=counter, sm=sources) update_bookmarks(drive) + assert params.value is not None assert params.value['count'] == 4 assert params.reads == params.writes == params.removes == 0 diff --git a/prebuilt.json b/prebuilt.json index 4e4086d761..91d93f2faf 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "cd4fa5f5def602d09c2d7fb638fbe3b4a600c7c735612d97623b5da6fb526176", "schema_version": 1} +{"protected_inventory_sha256": "3e5c60a01a1c91e2c04e025036427855ca11d783e40ac532dd0e6c144364e548", "schema_version": 1}