Skip to content

Validation API

Tier: Stable Core

Reports from Program.check(), rule metadata, and the project check settings.

pyrung.validation.ValidationReport dataclass

Unified report from all core validators.

errors

errors() -> tuple[Finding, ...]

Findings at error severity — the CI gate.

grouped

grouped() -> dict[str, list[FindingDisplay]]

Return the findings' displays keyed by rule code. The stuck-bit findings come last.

A block reset or fill can leave many coils stuck. Their stuck-bit findings share one display, so a 140-coil block clear reads as one entry.

pyrung.validation.Finding

Bases: Protocol

Structural contract shared by all validation findings.

display property

display: FindingDisplay

Presentation structure; message is display.as_text().

pyrung.validation.FindingDisplay dataclass

Everything a UI needs to render a finding — no string parsing required.

problem is a shared lead line, used when there is no single offending token to label (multi-site findings, or a contradiction). hint is the fix.

as_text

as_text() -> str

The classic flat message string, derived from the structure.

pyrung.validation.RuleSpec dataclass

Fully self-describing metadata for one validation rule code.

Everything a UI needs to display a rule lives here — code, category, severity, and a human title — so consumers (e.g. clicknick's Analyze Program window) render from the registry and never hard-code their own copy.

validator is a key into report's validator dispatch, not a callable, so several codes can share one pass (STUCK_HIGH/LOW; the PHYS + RANGE family).

pyrung.validation.ordered_rules

ordered_rules() -> tuple[RuleSpec, ...]

All rule specs in canonical display order: severity desc, then category, code.

The single source a UI iterates to lay out a report — most severe first.

pyrung.validation.default_on_rules

default_on_rules() -> frozenset[str]

The curated core checks active when select is not given.

pyrung.validation.CheckConfig dataclass

pyrung.validation.load_check_config

load_check_config(path: Path) -> CheckConfig | None

Read the [tool.pyrung.check] table of one pyproject.toml.

Return None if the file or the table is missing. Raise ValueError if the table names a rule code or category that pyrung does not know. The message names the file and the unknown name, so a config saved under an old rule name fails on load and is never ignored.

pyrung.validation.save_check_config

save_check_config(path: Path, config: CheckConfig) -> None

Update just the check settings, preserving other TOML values and comments.

pyrung.validation.find_check_config

find_check_config(
    start: Path,
) -> tuple[CheckConfig, Path | None]

Find the closest ancestor pyproject containing tool.pyrung.check.