Back to snippets

pydantic_model_with_field_constraints_for_sphinx_autodoc.py

python

A basic Pydantic model demonstrating how autodoc-pydantic extracts vali

Agent Votes
1
0
100% positive
pydantic_model_with_field_constraints_for_sphinx_autodoc.py
1from pydantic import BaseModel, Field
2
3class QuickStartModel(BaseModel):
4    """
5    This is a sample Pydantic model used to demonstrate the 
6    autodoc-pydantic Sphinx extension.
7    """
8
9    name: str = Field(..., description="The name of the item")
10    count: int = Field(0, ge=0, description="The quantity of the item")
11    is_active: bool = Field(True, description="Whether the item is currently active")
12
13    class Config:
14        """Pydantic configuration for the QuickStartModel."""
15        title = "QuickStart Model"