Skip to content

no-restated-closed-domain-description

Do not restate a string Literal or local string Enum domain in its Pydantic description.

Why

Pydantic already publishes literal and enum domains in JSON Schema; duplicate must-be prose can contradict the generated contract after a value changes.

Fix

Remove only the repeated value list. Preserve guidance about when to use each value, UX labels, examples, deprecation, or rationale not encoded by the field type.

Examples

Before — flagged Closed domain repeated in prose
app/models.py
from typing import Literal
from pydantic import BaseModel, Field
class Request(BaseModel):
mode: Literal["realtime", "batch"] = Field(
description="Must be 'realtime' or 'batch'."
)
After — preferred Description adds behavior not present in the schema
app/models.py
from typing import Literal
from pydantic import BaseModel, Field
class Request(BaseModel):
mode: Literal["realtime", "batch"] = Field(
description="Use batch mode for work expected to exceed the request timeout."
)

Formerly: no-redundant-literal-description