- pyproject.toml: add [tool.ruff] config suppressing E402/W293 globally, F841/E741/E702 in tests, E741 in scripts - inventory.py: split semicolon import (E702) - recipes.py: fix logger -> log (F821 undefined name) - shopping.py: rename l -> lnk in list comprehension (E741) - format_conversion.py: noqa F841 on CUDA flag (used as future hook) - backfill_keywords.py: rename done -> _done (F841) - ingest_purplecarrot.py: drop == True comparison (E712) - Auto-fix: I001 import sorting, F401 unused imports across all files
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
"""Pydantic schemas for the shopping list endpoints."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ShoppingItemCreate(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=200)
|
|
quantity: Optional[float] = None
|
|
unit: Optional[str] = None
|
|
category: Optional[str] = None
|
|
notes: Optional[str] = None
|
|
source: str = "manual"
|
|
recipe_id: Optional[int] = None
|
|
sort_order: int = 0
|
|
|
|
|
|
class ShoppingItemUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=200)
|
|
quantity: Optional[float] = None
|
|
unit: Optional[str] = None
|
|
category: Optional[str] = None
|
|
checked: Optional[bool] = None
|
|
notes: Optional[str] = None
|
|
sort_order: Optional[int] = None
|
|
|
|
|
|
class GroceryLinkOut(BaseModel):
|
|
ingredient: str
|
|
retailer: str
|
|
url: str
|
|
|
|
|
|
class ShoppingItemResponse(BaseModel):
|
|
id: int
|
|
name: str
|
|
quantity: Optional[float]
|
|
unit: Optional[str]
|
|
category: Optional[str]
|
|
checked: bool
|
|
notes: Optional[str]
|
|
source: str
|
|
recipe_id: Optional[int]
|
|
sort_order: int
|
|
created_at: str
|
|
updated_at: str
|
|
grocery_links: list[GroceryLinkOut] = []
|
|
|
|
|
|
class BulkAddFromRecipeRequest(BaseModel):
|
|
recipe_id: int
|
|
include_covered: bool = False # if True, add pantry-covered items too
|
|
|
|
|
|
class ConfirmPurchaseRequest(BaseModel):
|
|
"""Move a checked item into pantry inventory."""
|
|
location: str = "pantry"
|
|
quantity: Optional[float] = None # override the list quantity
|
|
unit: Optional[str] = None
|