Python: Address Copilot's comments

This commit is contained in:
Taus
2026-05-12 15:27:14 +00:00
parent f5c3b63a4a
commit 1ef557c972
3 changed files with 11 additions and 5 deletions

View File

@@ -1,9 +1,10 @@
/** /**
* Utility library for identifying timer annotations in evaluation-order tests. * Utility library for identifying timer annotations in evaluation-order tests.
* *
* Identifies `expr @ t[n]` (matmul), `t(expr, n)` (call), and * Identifies `expr @ t[n]` (matmul) and `t(expr, n)` (call) patterns,
* `expr @ t.dead[n]` (dead-code) patterns, extracts timestamp values, * including `dead(n)` and `never` markers within subscripts, extracts
* and provides predicates for traversing consecutive annotated CFG nodes. * timestamp values, and provides predicates for traversing consecutive
* annotated CFG nodes.
*/ */
import python import python

View File

@@ -5,7 +5,7 @@ are evaluated in the expected order (typically left to right for
operands of binary operators, elements of collection literals, etc.) operands of binary operators, elements of collection literals, etc.)
Every evaluated expression has a timestamp annotation, except the Every evaluated expression has a timestamp annotation, except the
timer mechanism itself (t[n], t.dead[n]). timer mechanism itself (t[n], t[dead(n)], t[never]).
""" """
from timer import test, never from timer import test, never

View File

@@ -26,6 +26,7 @@ Run a test file directly to self-validate: python test_file.py
""" """
import atexit import atexit
import os
import sys import sys
_results = [] _results = []
@@ -53,6 +54,10 @@ class _Check:
self._dead.add(e.timestamp) self._dead.add(e.timestamp)
elif isinstance(e, _NeverSentinel): elif isinstance(e, _NeverSentinel):
self._never = True self._never = True
else:
raise TypeError(
f"Unknown element in timer subscript: {e!r} (type {type(e).__name__})"
)
def __rmatmul__(self, value): def __rmatmul__(self, value):
ts = self._timer._tick() ts = self._timer._tick()
@@ -183,7 +188,7 @@ def _report():
print("---") print("---")
print(f"{passed}/{total} tests passed") print(f"{passed}/{total} tests passed")
if passed < total: if passed < total:
sys.exit(1) os._exit(1)
atexit.register(_report) atexit.register(_report)