Skip to content

climate_ref.doctor.findings #

What a check reports, and how serious it is.

Finding #

One problem found by a check.

Source code in packages/climate-ref/src/climate_ref/doctor/findings.py
@frozen
class Finding:
    """
    One problem found by a check.
    """

    severity: Severity
    """How much it matters."""

    summary: str
    """One line stating what is wrong."""

    detail: str = ""
    """Optional further explanation of this finding alone."""

    remedy: str = ""
    """
    Optional instruction for fixing it.

    Findings that share a remedy are reported under it once rather than repeating it,
    so keep the wording free of anything specific to one finding.
    """

    command: str = ""
    """
    Optional command that carries out the remedy.

    Held apart from ``remedy`` so it can be printed unwrapped and stay pasteable.
    """

    check: str = ""
    """
    Slug of the check that produced it, e.g. ``duplicate-coverage``.

    A check does not set this itself.
    The runner stamps it from the check's registration, so the slug has one definition.
    """

check = '' class-attribute instance-attribute #

Slug of the check that produced it, e.g. duplicate-coverage.

A check does not set this itself. The runner stamps it from the check's registration, so the slug has one definition.

command = '' class-attribute instance-attribute #

Optional command that carries out the remedy.

Held apart from remedy so it can be printed unwrapped and stay pasteable.

detail = '' class-attribute instance-attribute #

Optional further explanation of this finding alone.

remedy = '' class-attribute instance-attribute #

Optional instruction for fixing it.

Findings that share a remedy are reported under it once rather than repeating it, so keep the wording free of anything specific to one finding.

severity instance-attribute #

How much it matters.

summary instance-attribute #

One line stating what is wrong.

Severity #

Bases: StrEnum

How much a finding matters. Declared worst-first for reporting.

Source code in packages/climate-ref/src/climate_ref/doctor/findings.py
class Severity(StrEnum):
    """How much a finding matters. Declared worst-first for reporting."""

    ERROR = "error"
    """Results computed in this state are wrong."""

    WARNING = "warning"
    """Something the deployment probably did not intend, but results remain valid."""

    INFO = "info"
    """Worth knowing, no action required."""

ERROR = 'error' class-attribute instance-attribute #

Results computed in this state are wrong.

INFO = 'info' class-attribute instance-attribute #

Worth knowing, no action required.

WARNING = 'warning' class-attribute instance-attribute #

Something the deployment probably did not intend, but results remain valid.

worst_severity(findings) #

Return the most serious severity present, or None when there are no findings.

Parameters:

Name Type Description Default
findings Sequence[Finding]

The findings to inspect.

required

Returns:

Type Description
Severity | None

The worst severity present, or None when findings is empty.

Source code in packages/climate-ref/src/climate_ref/doctor/findings.py
def worst_severity(findings: Sequence[Finding]) -> Severity | None:
    """
    Return the most serious severity present, or ``None`` when there are no findings.

    Parameters
    ----------
    findings
        The findings to inspect.

    Returns
    -------
    :
        The worst severity present, or ``None`` when ``findings`` is empty.
    """
    for severity in SEVERITY_ORDER:
        if any(finding.severity == severity for finding in findings):
            return severity
    return None