Severity taxonomy

A review comment without a severity is noise. Reviewers have no way to triage between a missing docstring and a leaked API key. A tight three-level taxonomy (info, warning, critical) gives you just enough resolution to act, without drowning the model in enum options.

Matching exercise: Match findings to severities

Loading practice…

models.py
python
from pydantic import BaseModel, Field
from typing import Literal


class ReviewComment(BaseModel):
    """A single line-level review comment produced by the LLM reviewer."""
    file: str = Field(..., description="Path to the file being commented on")
    line: int = Field(..., description="Line number in the new version of the file")
    severity: Literal["info", "warning", "critical"] = "info"
    suggestion: str = Field(..., description="Actionable suggestion for the author")

Literal["info", "warning", "critical"] is the Pydantic-native way to constrain a field to an enum. If the LLM returns "minor" or "error", Pydantic raises a validation error and the comment is dropped. That is the whole point: bad taxonomy never reaches GitHub.

No. More levels sound more granular, but they push the model toward middle-of-the-road answers that never commit. Three levels force a decision: is this actionable now (warning), blocking (critical), or just worth knowing (info). Any reviewer can triage that quickly. More levels waste both your tokens and your reviewer attention.

Quiz: Quiz

Loading practice…