from datetime import datetime from typing import Optional from pydantic import BaseModel, Field class TodoBase(BaseModel): """Base Todo schema with common attributes.""" title: str = Field(..., min_length=1, max_length=100, description="Title of the todo item") description: Optional[str] = Field(None, description="Detailed description of the todo item") completed: bool = Field(False, description="Whether the todo item is completed") class TodoCreate(TodoBase): """Schema for creating a new todo item.""" pass class TodoUpdate(BaseModel): """Schema for updating an existing todo item.""" title: Optional[str] = Field( None, min_length=1, max_length=100, description="Title of the todo item" ) description: Optional[str] = Field(None, description="Detailed description of the todo item") completed: Optional[bool] = Field(None, description="Whether the todo item is completed") class TodoInDB(TodoBase): """Schema for a todo item as stored in the database.""" id: int created_at: datetime updated_at: datetime class Config: """Pydantic config.""" orm_mode = True class Todo(TodoInDB): """Schema for a todo item returned by the API.""" pass class TodoList(BaseModel): """Schema for a list of todo items.""" items: list[Todo] count: int