From 85542e443b8de8523c3033a696466b912c50ad5d Mon Sep 17 00:00:00 2001 From: glenn schrooyen Date: Tue, 20 Oct 2026 01:38:24 +0200 Subject: [PATCH] SAFETY-119 round 2: test_safety119 reads through named_absence test_named_absence flagged two unguarded reads (next() without a default, a list indexed in a check name). Use first(), nth() and present(). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC --- goodwe_controller/test_safety119.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/goodwe_controller/test_safety119.py b/goodwe_controller/test_safety119.py index 0836f04..02c958c 100644 --- a/goodwe_controller/test_safety119.py +++ b/goodwe_controller/test_safety119.py @@ -53,6 +53,7 @@ import app.main as app_main # noqa: E402 from app import messages # noqa: E402 from app.main import Controller # noqa: E402 from app.p1 import make_sample, split_signed # noqa: E402 +from named_absence import first, nth, present # noqa: E402 fails = [] OPT0 = dict(s84.OPT) @@ -437,10 +438,10 @@ check(f"at 5 s, one bound cycle per turn: {M} are hidden, the {M + 1}th and " _hid == [True] * M + [False] * (20 - M)) _c = _C() _o, _ = turns(_c, 1.0, 2, 1, 12) -_first = next(t for t, h in _o if not h) +_first, _o0 = first(t for t, h in _o if not h), nth(_o, 0)[0] check(f"at 1 s the span holds too: not counted before {SPAN:.0f} s after " f"the first hidden one (counted at {_first:.0f} s)", - _o[0][0] + SPAN <= _first <= _o[0][0] + SPAN + 3.0 + present(_first, _o0) and _o0 + SPAN <= _first <= _o0 + SPAN + 3.0 and sum(h for _t, h in _o) > M) _c = _C() _t = 0.0