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]: Errors UNIT01–UNIT04 and UNIT06 (implementation, contract and missing intent), EVAL01–EVAL04 (evaluations), DEL01/DEL02 (consumers) and PROV01 (unknown decision), plus warnings for unused declarations.

Examples

from pathlib import Path
from tempfile import TemporaryDirectory

from spotregen 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())
[]
ERROR   DEL01   samplepkg.core.calc: scripts/use_it.py depends on the unit but is not a declared consumer