- Introduced `lint` and `lint-fix` applications in `flake.nix` for unified linting of backend (Python) and frontend (TypeScript/Svelte) code. - Added `scripts/lint.sh` for manual linting execution. - Created `scripts/install-hooks.sh` to set up git hooks for automatic linting before commits and optional tests before pushes. - Updated `README.md` with instructions for using the new linting features and git hooks.
58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
"""Base Pydantic schemas."""
|
|
|
|
from datetime import datetime
|
|
from typing import Any
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class BaseSchema(BaseModel):
|
|
"""Base schema with common configuration."""
|
|
|
|
model_config = ConfigDict(from_attributes=True, populate_by_name=True, json_schema_extra={"example": {}})
|
|
|
|
|
|
class TimestampSchema(BaseSchema):
|
|
"""Schema with timestamp fields."""
|
|
|
|
created_at: datetime = Field(..., description="Creation timestamp")
|
|
updated_at: datetime | None = Field(None, description="Last update timestamp")
|
|
|
|
|
|
class IDSchema(BaseSchema):
|
|
"""Schema with ID field."""
|
|
|
|
id: UUID = Field(..., description="Unique identifier")
|
|
|
|
|
|
class ResponseSchema(BaseSchema):
|
|
"""Generic response schema."""
|
|
|
|
message: str = Field(..., description="Response message")
|
|
data: dict[str, Any] | None = Field(None, description="Response data")
|
|
|
|
|
|
class ErrorSchema(BaseSchema):
|
|
"""Error response schema."""
|
|
|
|
error: str = Field(..., description="Error message")
|
|
details: dict[str, Any] | None = Field(None, description="Error details")
|
|
status_code: int = Field(..., description="HTTP status code")
|
|
|
|
|
|
class PaginationSchema(BaseSchema):
|
|
"""Pagination metadata schema."""
|
|
|
|
total: int = Field(..., description="Total number of items")
|
|
page: int = Field(..., description="Current page number")
|
|
page_size: int = Field(..., description="Items per page")
|
|
total_pages: int = Field(..., description="Total number of pages")
|
|
|
|
|
|
class PaginatedResponse(BaseSchema):
|
|
"""Paginated response schema."""
|
|
|
|
items: list[Any] = Field(..., description="List of items")
|
|
pagination: PaginationSchema = Field(..., description="Pagination metadata")
|