from typing import Optional from pydantic import BaseModel, EmailStr, Field class UserBase(BaseModel): """ Base user schema with common attributes. """ username: str = Field(..., description="Username for login") email: EmailStr = Field(..., description="User's email address") full_name: Optional[str] = Field(None, description="User's full name") is_active: bool = Field(True, description="Whether the user is active") is_superuser: bool = Field(False, description="Whether the user has admin privileges") class UserCreate(UserBase): """ Schema for user creation with password. """ password: str = Field(..., description="User's password") class UserUpdate(BaseModel): """ Schema for updating user information. """ username: Optional[str] = Field(None, description="Username for login") email: Optional[EmailStr] = Field(None, description="User's email address") full_name: Optional[str] = Field(None, description="User's full name") password: Optional[str] = Field(None, description="User's password") is_active: Optional[bool] = Field(None, description="Whether the user is active") is_superuser: Optional[bool] = Field(None, description="Whether the user has admin privileges") class UserInDBBase(UserBase): """ Base schema for users from the database. """ id: int = Field(..., description="User ID") class Config: from_attributes = True class User(UserInDBBase): """ Schema for user information returned to clients. """ pass class UserInDB(UserInDBBase): """ Schema for user in database including hashed password. """ hashed_password: str = Field(..., description="Hashed password")