style: apply black and isort formatting across entire codebase
- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,21 +5,24 @@ Pydantic schemas for shopping cart operations.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
# ============================================================================
|
||||
# Request Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class AddToCartRequest(BaseModel):
|
||||
"""Request model for adding items to cart."""
|
||||
|
||||
product_id: int = Field(..., description="Product ID to add", gt=0)
|
||||
quantity: int = Field(1, ge=1, description="Quantity to add")
|
||||
|
||||
|
||||
class UpdateCartItemRequest(BaseModel):
|
||||
"""Request model for updating cart item quantity."""
|
||||
|
||||
quantity: int = Field(..., ge=1, description="New quantity (must be >= 1)")
|
||||
|
||||
|
||||
@@ -27,23 +30,30 @@ class UpdateCartItemRequest(BaseModel):
|
||||
# Response Schemas
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class CartItemResponse(BaseModel):
|
||||
"""Response model for a single cart item."""
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
product_id: int = Field(..., description="Product ID")
|
||||
product_name: str = Field(..., description="Product name")
|
||||
quantity: int = Field(..., description="Quantity in cart")
|
||||
price: float = Field(..., description="Price per unit when added to cart")
|
||||
line_total: float = Field(..., description="Total price for this line (price * quantity)")
|
||||
line_total: float = Field(
|
||||
..., description="Total price for this line (price * quantity)"
|
||||
)
|
||||
image_url: Optional[str] = Field(None, description="Product image URL")
|
||||
|
||||
|
||||
class CartResponse(BaseModel):
|
||||
"""Response model for shopping cart."""
|
||||
|
||||
vendor_id: int = Field(..., description="Vendor ID")
|
||||
session_id: str = Field(..., description="Shopping session ID")
|
||||
items: List[CartItemResponse] = Field(default_factory=list, description="Cart items")
|
||||
items: List[CartItemResponse] = Field(
|
||||
default_factory=list, description="Cart items"
|
||||
)
|
||||
subtotal: float = Field(..., description="Subtotal of all items")
|
||||
total: float = Field(..., description="Total amount (currently same as subtotal)")
|
||||
item_count: int = Field(..., description="Total number of items in cart")
|
||||
@@ -63,18 +73,22 @@ class CartResponse(BaseModel):
|
||||
items=items,
|
||||
subtotal=cart_dict["subtotal"],
|
||||
total=cart_dict["total"],
|
||||
item_count=len(items)
|
||||
item_count=len(items),
|
||||
)
|
||||
|
||||
|
||||
class CartOperationResponse(BaseModel):
|
||||
"""Response model for cart operations (add, update, remove)."""
|
||||
|
||||
message: str = Field(..., description="Operation result message")
|
||||
product_id: int = Field(..., description="Product ID affected")
|
||||
quantity: Optional[int] = Field(None, description="New quantity (for add/update operations)")
|
||||
quantity: Optional[int] = Field(
|
||||
None, description="New quantity (for add/update operations)"
|
||||
)
|
||||
|
||||
|
||||
class ClearCartResponse(BaseModel):
|
||||
"""Response model for clearing cart."""
|
||||
|
||||
message: str = Field(..., description="Operation result message")
|
||||
items_removed: int = Field(..., description="Number of items removed from cart")
|
||||
|
||||
Reference in New Issue
Block a user