refactor: modernize code quality tooling with Ruff

- Replace black, isort, and flake8 with Ruff (all-in-one linter and formatter)
- Add comprehensive pyproject.toml configuration
- Simplify Makefile code quality targets
- Configure exclusions for venv/.venv in pyproject.toml
- Auto-fix 1,359 linting issues across codebase

Benefits:
- Much faster builds (Ruff is written in Rust)
- Single tool replaces multiple tools
- More comprehensive rule set (UP, B, C4, SIM, PIE, RET, Q)
- All configuration centralized in pyproject.toml
- Better import sorting and formatting consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 19:37:38 +01:00
parent 21c13ca39b
commit 238c1ec9b8
169 changed files with 2183 additions and 1784 deletions

View File

@@ -11,15 +11,17 @@ This module provides:
import logging
import random
import string
from datetime import datetime, timezone
from typing import List, Optional, Tuple
from datetime import UTC, datetime
from sqlalchemy import and_, or_
from sqlalchemy import and_
from sqlalchemy.orm import Session
from app.exceptions import (CustomerNotFoundException,
InsufficientInventoryException,
OrderNotFoundException, ValidationException)
from app.exceptions import (
CustomerNotFoundException,
InsufficientInventoryException,
OrderNotFoundException,
ValidationException,
)
from models.database.customer import Customer, CustomerAddress
from models.database.order import Order, OrderItem
from models.database.product import Product
@@ -38,7 +40,7 @@ class OrderService:
Format: ORD-{VENDOR_ID}-{TIMESTAMP}-{RANDOM}
Example: ORD-1-20250110-A1B2C3
"""
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d")
timestamp = datetime.now(UTC).strftime("%Y%m%d")
random_suffix = "".join(
random.choices(string.ascii_uppercase + string.digits, k=6)
)
@@ -266,9 +268,9 @@ class OrderService:
vendor_id: int,
skip: int = 0,
limit: int = 100,
status: Optional[str] = None,
customer_id: Optional[int] = None,
) -> Tuple[List[Order], int]:
status: str | None = None,
customer_id: int | None = None,
) -> tuple[list[Order], int]:
"""
Get orders for vendor with filtering.
@@ -306,7 +308,7 @@ class OrderService:
customer_id: int,
skip: int = 0,
limit: int = 100,
) -> Tuple[List[Order], int]:
) -> tuple[list[Order], int]:
"""Get orders for a specific customer."""
return self.get_vendor_orders(
db=db, vendor_id=vendor_id, skip=skip, limit=limit, customer_id=customer_id
@@ -335,7 +337,7 @@ class OrderService:
order.status = order_update.status
# Update timestamp based on status
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
if order_update.status == "shipped" and not order.shipped_at:
order.shipped_at = now
elif order_update.status == "delivered" and not order.delivered_at:
@@ -351,7 +353,7 @@ class OrderService:
if order_update.internal_notes:
order.internal_notes = order_update.internal_notes
order.updated_at = datetime.now(timezone.utc)
order.updated_at = datetime.now(UTC)
db.commit()
db.refresh(order)