gui.model.filter_findings

gui.model.filter_findings(
    findings,
    text='',
    levels=('error', 'warning'),
    codes=(),
)

Select the findings the Check view shows.

Parameters

Name Type Description Default
findings Iterable[Finding] All findings. required
text str Keep findings whose rendered line contains this text, ignoring case. ''
levels Iterable[str] Keep these levels. ('error', 'warning')
codes Iterable[str] Keep these codes; empty keeps all. ()

Returns

Name Type Description
list[Finding] list[Finding]: The selection, in the original order.

Examples

from spotregen import Finding
from spotregen.gui.model import filter_findings

findings = [
    Finding("error", "ARCH01", "src/a.py", "forbidden import"),
    Finding("warning", "DEL03", "core.calc", "no longer used"),
]
print(len(filter_findings(findings, levels=["error"])))
print(len(filter_findings(findings, text="CALC")))
1
1