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.
This commit is contained in:
Dom
2026-11-16 23:09:29 -06:00
parent ffd70cafe3
commit f932fc8a18
3 changed files with 4 additions and 4 deletions
@@ -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')]
@@ -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)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "905ad2bae8c74b3789b7bd6aca99e2d4437f7d00562624af78b1e39822b07ce3", "schema_version": 1}
{"protected_inventory_sha256": "da97a597352ea19ff2b5d9110cd63fed4ca92f2850802a9a9d6ad847c862ff9d", "schema_version": 1}