from typing import Annotated from pydantic import BaseModel, BeforeValidator, ConfigDict, EmailStr from src.schemas.tasks import TaskWithId from src.schemas.validators import ensure_password, ensure_username class UserUpdate(BaseModel): email: EmailStr | None = None username: str | None = None is_active: bool | None = None model_config = ConfigDict(from_attributes=True, extra="ignore") class User(BaseModel): id: int email: EmailStr | None username: str is_active: bool is_superuser: bool telegram_id: int | None avatar_path: str | None model_config = ConfigDict(from_attributes=True, extra="ignore") class UserWithHashedPass(User): hashed_password: str class UserWithTasks(User): tasks: list[TaskWithId] class UserRequest(BaseModel): username: str password: str class UserRequestADD(BaseModel): username: Annotated[str, BeforeValidator(ensure_username)] email: EmailStr | None = None password: Annotated[str, BeforeValidator(ensure_password)] class UserAdd(BaseModel): email: EmailStr | None username: str hashed_password: str