Skip to content

no-impossible-pydantic-field-bounds

Pydantic field bounds must admit at least one value.

Why

Contradictory literal constraints reject every field value, including integer multiples and float intervals with no representable member.

Fix

Correct the conflicting bounds so the declared field domain admits the intended values.

Examples

Before — flagged No integer lies strictly between zero and one
app/models.py
from pydantic import BaseModel, Field
class Model(BaseModel):
value: int = Field(gt=0, lt=1)
After — preferred Zero is admitted by the interval
app/models.py
from pydantic import BaseModel, Field
class Model(BaseModel):
value: int = Field(ge=0, lt=1)