from datetime import datetime from typing import Optional from pydantic import BaseModel, ConfigDict, EmailStr, Field class UserBase(BaseModel): """ Base user schema with shared attributes """ email: EmailStr username: str full_name: Optional[str] = None is_active: bool = True class UserCreate(UserBase): """ Schema for user creation with password """ password: str = Field(..., min_length=8) class UserUpdate(BaseModel): """ Schema for user updates """ email: Optional[EmailStr] = None username: Optional[str] = None full_name: Optional[str] = None password: Optional[str] = Field(None, min_length=8) is_active: Optional[bool] = None class UserInDBBase(UserBase): """ Base schema for users in DB with id and timestamps """ id: int created_at: datetime updated_at: datetime is_superuser: bool = False model_config = ConfigDict(from_attributes=True) class User(UserInDBBase): """ Schema for returning user information """ pass class UserInDB(UserInDBBase): """ Schema with hashed password for internal use """ hashed_password: str