Skip to main content

checks.Finding

checks.Finding(level, id, path, line, message, suggestion=None)

One result of a check.

Attributes

Name Type Description
level str "error" (fails the check) or "warning".
id str Stable ID, named after a primitive, for example "COMPILE02". The levels and conditions are in babregen.checks.CHECKS.
path str Repository-relative POSIX path of the file the finding is about: a record, a source file, an evaluation file or a run record.
line int | None 1-based line in path, or None when the check cannot tell.
message str What is wrong and, where possible, how to fix it. It names the unit where path does not.
suggestion str | None A similar valid name when the finding is about a name that matches nothing (EVAL03, PROV01, PROV02, COMPILE06, COMPILE08) and a close one exists, else None.

All six fields take part in equality.

Examples

from babregen import Finding

finding = Finding(
    "error", "COMPILE02", "src/samplepkg/core/bad.py", 1, "forbidden import"
)
print(finding.format())
src/samplepkg/core/bad.py:1: error COMPILE02 forbidden import

Methods

Name Description
format Render the finding as one line for a terminal.

format

checks.Finding.format()

Render the finding as one line for a terminal.

Returns

Name Type Description
str str {path}:{line}: {level} {id} {message}, or {path}: {level} {id} {message} when line is None. The level is lower case and nothing is padded. A finding with a suggestion ends with ; a similar name exists: 'X'.

Examples

from babregen import Finding

print(Finding("warning", "COMPACT04", "regen/units/u.toml", 3, "unused").format())
print(Finding("warning", "COMPACT04", "regen/units/u.toml", None, "unused").format())
regen/units/u.toml:3: warning COMPACT04 unused
regen/units/u.toml: warning COMPACT04 unused