Skip to content
Sarj Code Standards

no-restated-closed-domain-description

Do not restate a field's names or its string Literal or local string Enum domain in its Pydantic description.

Why

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

Fix

Remove a description that only repeats names, or 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