Coverage for lintro / ai / enums / risk_level.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Risk level enumeration for AI fix suggestions."""
3from __future__ import annotations
5from enum import auto
7from lintro.enums.hyphenated_str_enum import HyphenatedStrEnum
10class RiskLevel(HyphenatedStrEnum):
11 """Risk classification for AI fix suggestions."""
13 SAFE_STYLE = auto()
14 BEHAVIORAL_RISK = auto()
16 def to_severity_label(self, *, sarif: bool = False) -> str:
17 """Map risk level to a severity label.
19 Args:
20 sarif: When True, return ``"note"`` for safe-style fixes
21 (SARIF format). When False, return ``"notice"``
22 (GitHub Actions annotation format).
24 Returns:
25 One of ``"warning"``, ``"note"``, or ``"notice"``.
26 """
27 if self == RiskLevel.SAFE_STYLE:
28 return "note" if sarif else "notice"
29 return "warning"