A skill to stop your coding agent from burying the answer. ADHD-friendly output.
style: simplify eval type annotations
Ayoub G.44d9630f1e7e
diff --git a/scripts/judge.py b/scripts/judge.pyindex 3b2b736..85c6de9 100644--- a/scripts/judge.py+++ b/scripts/judge.py@@ -1,18 +1,15 @@#!/usr/bin/env python3"""Blind-judge paired evaluation responses and emit scorable rows."""-from __future__ import annotations-import argparseimport hashlibimport jsonimport subprocess-import tempfileimport sysimport timefrom collections import defaultdictfrom pathlib import Path-from typing import Any+from typing import Any, Optionalsys.path.insert(0, str(Path(__file__).resolve().parent))@@ -173,7 +170,7 @@ def assign_labels(group_key: tuple, conditions: list[str]) -> dict[str, str]:def invoke_judge(command: list[str], response_format: str, prompt: str, retries: int-) -> tuple[str, float | None]:+) -> tuple[str, Optional[float]]:"""Run the judge runner once, retrying transient failures.The prompt goes in on stdin rather than as a trailing argument: a runner@@ -211,14 +208,14 @@ def _judge_group(group_key: tuple,labels: dict[str, str],retries: int,-) -> tuple[list[dict[str, Any]], float | None]:+) -> tuple[list[dict[str, Any]], Optional[float]]:"""Invoke the judge and parse its verdict, retrying a malformed reply.A grader occasionally drops a field or emits prose around the JSON. That isa transient formatting failure rather than a permanent one, so it is worththe same retry budget as a failed process before the group is abandoned."""- last_error: ValueError | None = None+ last_error: Optional[ValueError] = Nonefor attempt in range(retries + 1):text, cost = invoke_judge(command, response_format, prompt, retries)try:@@ -245,14 +242,17 @@ def _build_parser() -> argparse.ArgumentParser:nargs="+",choices=sorted(run_evals.CONDITIONS),default=["baseline", "candidate"],- help="Conditions that every response group must contain (default: baseline candidate).",+ help=(+ "Conditions that every response group must contain "+ "(default: baseline candidate)."+ ),)parser.add_argument("--retries", type=int, default=2)parser.add_argument("--output", type=Path, required=True)return parser-def main(argv: list[str] | None = None) -> int:+def main(argv: Optional[list[str]] = None) -> int:args = _build_parser().parse_args(argv)rubric = grader_rubric(args.rubric.read_text(encoding="utf-8"))cases = {case["id"]: case for case in run_evals.load_cases(args.cases)}diff --git a/scripts/run_evals.py b/scripts/run_evals.pyindex 1f6f629..064d763 100644--- a/scripts/run_evals.py+++ b/scripts/run_evals.py@@ -1,8 +1,6 @@#!/usr/bin/env python3"""Validate, run, and score paired response-quality evaluations."""-from __future__ import annotations-import argparsefrom contextlib import contextmanagerimport json@@ -14,7 +12,7 @@ import timefrom collections import Counter, defaultdictfrom collections.abc import Iteratorfrom pathlib import Path-from typing import Any+from typing import Any, OptionalROOT = Path(__file__).resolve().parents[1]@@ -204,7 +202,7 @@ def _strip_frontmatter(text: str) -> str:return text-def _condition_prompt(task: str, condition: str, skill_path: Path | None) -> str:+def _condition_prompt(task: str, condition: str, skill_path: Optional[Path]) -> str:if condition == "baseline":return taskif skill_path is None:@@ -218,7 +216,9 @@ def _condition_prompt(task: str, condition: str, skill_path: Path | None) -> str)-def _parse_response(output: str, response_format: str) -> tuple[str, dict[str, Any], float | None]:+def _parse_response(+ output: str, response_format: str+) -> tuple[str, dict[str, Any], Optional[float]]:if response_format == "text":return output.strip(), {}, Noneif response_format == "claude-json":@@ -371,7 +371,7 @@ def _build_parser() -> argparse.ArgumentParser:return parser-def main(argv: list[str] | None = None) -> int:+def main(argv: Optional[list[str]] = None) -> int:parser = _build_parser()args = parser.parse_args(argv)if hasattr(args, "handler"):diff --git a/tests/test_judge.py b/tests/test_judge.pyindex 8a61094..7e6e86e 100644--- a/tests/test_judge.py+++ b/tests/test_judge.py@@ -336,7 +336,14 @@ class EndToEndTest(unittest.TestCase):output = tmp_path / "scores.jsonl"runner_config = tmp_path / "runners.json"runner_config.write_text(- json.dumps({"stub": {"command": ["sh", "-c", "exit 99"], "response_format": "text"}})+ json.dumps(+ {+ "stub": {+ "command": ["sh", "-c", "exit 99"],+ "response_format": "text",+ }+ }+ ))with self.assertRaisesRegex(ValueError, "missing required condition"):