From f932fc8a182368fb2b6bd2cd8ec11337e163dc4e Mon Sep 17 00:00:00 2001 From: Dom <168790843+firestar5683@users.noreply.github.com> Date: Mon, 16 Nov 2026 23:09:29 -0600 Subject: [PATCH] Make exact numeric guards and existing platform skip type-check Preserve exact builtin numeric admission, bool/subclass rejection, overflow handling and existing non-Linux ELF skip exception. 68 focused acceptance/MPU tests pass; Darwin-target project type checking and Ruff pass. Native outputs unchanged; refresh validated inventory only. --- openpilot/starpilot/aol/tests/test_panda_mpu_aol.py | 2 +- openpilot/starpilot/speed_limits/acceptance.py | 4 ++-- prebuilt.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openpilot/starpilot/aol/tests/test_panda_mpu_aol.py b/openpilot/starpilot/aol/tests/test_panda_mpu_aol.py index 5678ab9995..5073acdc8d 100644 --- a/openpilot/starpilot/aol/tests/test_panda_mpu_aol.py +++ b/openpilot/starpilot/aol/tests/test_panda_mpu_aol.py @@ -14,7 +14,7 @@ ROOT = Path(__file__).resolve().parents[4] @pytest.fixture(scope='module', params=[False, True], ids=['DEBUG', 'RELEASE']) def native_template(tmp_path_factory, request): if not sys.platform.startswith('linux'): - pytest.skip('The native safety-state linker section requires ELF') + raise pytest.skip.Exception('The native safety-state linker section requires ELF') directory = tmp_path_factory.mktemp('mpu-aol') comms = (ROOT / 'panda/board/main_comms.h').read_text() matches = [re.search(rf' case 0x{value}:.*?(?= //| case)', comms, re.DOTALL) for value in ('d5', 'f5')] diff --git a/openpilot/starpilot/speed_limits/acceptance.py b/openpilot/starpilot/speed_limits/acceptance.py index d1b6639b0c..b297128af2 100644 --- a/openpilot/starpilot/speed_limits/acceptance.py +++ b/openpilot/starpilot/speed_limits/acceptance.py @@ -178,7 +178,7 @@ def float32(value: float) -> float: def number(value: object, *, positive: bool = False) -> TypeGuard[int | float]: - if type(value) not in (int, float): + if type(value) is not int and type(value) is not float: return False try: # A saved or decoded value can be an int too large for math.isfinite. @@ -190,7 +190,7 @@ def number(value: object, *, positive: bool = False) -> TypeGuard[int | float]: # The only predicate that admits a negative, since offsets may be below zero. Not # built on number(), whose own guard must stay a single call on the per-frame path. def finite(value: object) -> TypeGuard[int | float]: - if type(value) not in (int, float): + if type(value) is not int and type(value) is not float: return False try: return math.isfinite(value) diff --git a/prebuilt.json b/prebuilt.json index 813755de37..f54c5a5322 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "905ad2bae8c74b3789b7bd6aca99e2d4437f7d00562624af78b1e39822b07ce3", "schema_version": 1} +{"protected_inventory_sha256": "da97a597352ea19ff2b5d9110cd63fed4ca92f2850802a9a9d6ad847c862ff9d", "schema_version": 1}