Skip to main content

checks.check_unit

checks.check_unit(spec, unit)

Check one unit against its implementation, its evaluations and its consumers.

Parameters

Name Type Description Default
spec RegenSpec The loaded spec. required
unit Unit The unit to check. required

Returns

Name Type Description
list[Finding] list[Finding]: INTENT01/INTENT02 (intent), PACE01, PACE02 and PACE04 (pace), COMPILE01 and COMPILE05–COMPILE08 (implementation, contract and dependencies), EVAL01–EVAL05 (evaluations), PROV01/PROV07 (decisions the intent cites), DELETE01–DELETE03 (consumers), plus the warnings COMPACT04, COMPACT05, COMPACT07, and PROV08/ PROV09 when the newest archived run under regen/runs/ judged another bundle or module than the current one. INTENT02 and EVAL03 read the evaluations from babregen.scan.defined_evaluations, the definition that babregen measures uses for coverage. A module that is missing (COMPILE05) or does not parse (COMPILE01, which check_architecture reports too) ends the check of the unit after the checks of its record (pace, intent, coverage).

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from babregen import check_unit, load_spec, make_sample_repo

with TemporaryDirectory() as tmp:
    root = make_sample_repo(Path(tmp) / "demo")
    spec = load_spec(root)
    unit = spec.units["samplepkg.core.calc"]
    print(check_unit(spec, unit))
    (root / "scripts").mkdir()
    (root / "scripts/use_it.py").write_text("from samplepkg.core import calc\n")
    for finding in check_unit(spec, unit):
        print(finding.format())
[]
regen/units/core.calc.toml:1: error DELETE01 scripts/use_it.py depends on the unit but is not a declared consumer