checks.Finding

checks.Finding(level, code, where, message, path=None, line=None)

One result of a check.

Attributes

Name Type Description
level str "error" (fails the check) or "warning".
code str Short stable code, for example "ARCH01".
where str The file or unit the finding is about.
message str What is wrong and, where possible, how to fix it.
path str | None Repository-relative POSIX path of the file to open, or None. Not part of format() and not compared.
line int | None 1-based line in path, or None when the check cannot tell. Not part of format() and not compared.

Examples

from spotregen import Finding

finding = Finding("error", "ARCH01", "src/samplepkg/core/bad.py", "forbidden import")
print(finding.format())
ERROR   ARCH01  src/samplepkg/core/bad.py: 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 LEVEL CODE where: message, the level padded to 7 and the code to 7 characters.

Examples

from spotregen import Finding

print(Finding("warning", "UNIT05", "samplepkg.core.calc", "unused").format())
WARNING UNIT05  samplepkg.core.calc: unused