Answer principles round 1: 0 🔴, 3 🟡 (0 misread); type-check every tool for README's Python, check the worker count, pin pytest
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from machine_load.slots import CPUS_PER_SLOT
|
||||
from repo_checks import ROOT
|
||||
|
||||
|
||||
class TestLine(unittest.TestCase):
|
||||
def test_the_readme_runs_the_tests_in_one_heavy_slots_cpus(self):
|
||||
workers = re.search(r"pytest==\S+ -n (\d+) bin`", (ROOT / "README.md").read_text(encoding="utf-8"))
|
||||
self.assertIsNotNone(workers, "README.md's Test line runs `pytest==X -n N bin`")
|
||||
self.assertEqual(int(workers.group(1)), CPUS_PER_SLOT)
|
||||
@@ -1,4 +1,5 @@
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -8,10 +9,26 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from repo_checks import ROOT
|
||||
|
||||
SUPPORTED = re.compile(r"the latest stable Python, today (3\.\d+)")
|
||||
|
||||
|
||||
def tools() -> list[str]:
|
||||
"""mypy's arguments naming every package and module under bin/ but the repo checks, so a new tool is checked without being listed."""
|
||||
bin_folder = ROOT / "bin"
|
||||
packages = sorted(init.parent.name for init in bin_folder.glob("*/__init__.py") if init.parent.name != "repo_checks")
|
||||
modules = sorted(path.stem for path in bin_folder.glob("*.py") if not path.name.startswith("test_"))
|
||||
return [*(word for package in packages for word in ("-p", package)), *(word for module in modules for word in ("-m", module))]
|
||||
|
||||
|
||||
class Types(unittest.TestCase):
|
||||
def test_mypy_passes_on_the_tools_for_the_python_running_the_tests(self):
|
||||
def test_mypy_passes_on_the_tools_for_the_python_readme_install_names(self):
|
||||
supported = SUPPORTED.search((ROOT / "README.md").read_text(encoding="utf-8"))
|
||||
self.assertIsNotNone(supported, "README.md's Install names `the latest stable Python, today 3.N`")
|
||||
if shutil.which("uv") is None:
|
||||
self.fail("uv on PATH fetches mypy; see README.md's Test line")
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", sys.executable, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", "-p", "chunk_preflight", "-p", "claude_code", "-m", "comprehension_history", "-m", "git_repo", "-p", "judge_replay", "-p", "larv_review", "-p", "loop_claude", "-m", "markdown_text", "-p", "metric_bench", "-m", "project_key", "-m", "rank_todo", "-p", "reading_cost", "-m", "review_passes", "-p", "review_replay", "-m", "round_titles", "-p", "rule_hook", "-p", "rung_replay", "-p", "score_outcomes", "-m", "settings_filter", "-m", "shell_command", "-m", "statusline", "-p", "subagent_rung", "-m", "todo_table", "-p", "transcript_archive", "-m", "utc_stamp"], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", sys.executable, "mypy==2.3.1", "--python-version", supported.group(1), "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", *tools()], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
|
||||
|
||||
def test_mypy_checks_run_heavy_and_each_root_module(self):
|
||||
self.assertLessEqual({("-p", "run_heavy"), ("-p", "machine_load"), ("-m", "chunk_pick"), ("-m", "docker_command")}, set(zip(tools()[::2], tools()[1::2])))
|
||||
self.assertNotIn("repo_checks", tools())
|
||||
|
||||
Reference in New Issue
Block a user