
- Fixed Pydantic configuration using ConfigDict for latest Pydantic version - Fixed import order in alembic/env.py for proper module imports - Applied code formatting with Ruff - Optimized database connection settings - Ensured proper error handling for API endpoints generated with BackendIM... (backend.im)
27 lines
683 B
Python
27 lines
683 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
|
|
class CalculationBase(BaseModel):
|
|
operation: str = Field(
|
|
...,
|
|
description="Mathematical operation: add, subtract, multiply, divide, or square_root",
|
|
)
|
|
first_number: float = Field(..., description="First operand")
|
|
second_number: Optional[float] = Field(
|
|
None, description="Second operand (not required for square_root)"
|
|
)
|
|
|
|
|
|
class CalculationCreate(CalculationBase):
|
|
pass
|
|
|
|
|
|
class CalculationResponse(CalculationBase):
|
|
id: int
|
|
result: float
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|