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:
@@ -11,7 +11,6 @@ This module provides classes and functions for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Union
|
||||
|
||||
from fastapi import HTTPException, Request
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
@@ -280,7 +279,7 @@ def setup_exception_handlers(app):
|
||||
request=request,
|
||||
status_code=404,
|
||||
error_code="ENDPOINT_NOT_FOUND",
|
||||
message=f"The page you're looking for doesn't exist or has been moved.",
|
||||
message="The page you're looking for doesn't exist or has been moved.",
|
||||
details={"path": request.url.path},
|
||||
show_debug=True,
|
||||
)
|
||||
@@ -364,10 +363,10 @@ def _redirect_to_login(request: Request) -> RedirectResponse:
|
||||
if context_type == RequestContext.ADMIN:
|
||||
logger.debug("Redirecting to /admin/login")
|
||||
return RedirectResponse(url="/admin/login", status_code=302)
|
||||
elif context_type == RequestContext.VENDOR_DASHBOARD:
|
||||
if context_type == RequestContext.VENDOR_DASHBOARD:
|
||||
logger.debug("Redirecting to /vendor/login")
|
||||
return RedirectResponse(url="/vendor/login", status_code=302)
|
||||
elif context_type == RequestContext.SHOP:
|
||||
if context_type == RequestContext.SHOP:
|
||||
# For shop context, redirect to shop login (customer login)
|
||||
# Calculate base_url for proper routing (supports domain, subdomain, and path-based access)
|
||||
vendor = getattr(request.state, "vendor", None)
|
||||
@@ -390,10 +389,9 @@ def _redirect_to_login(request: Request) -> RedirectResponse:
|
||||
login_url = f"{base_url}shop/account/login"
|
||||
logger.debug(f"Redirecting to {login_url}")
|
||||
return RedirectResponse(url=login_url, status_code=302)
|
||||
else:
|
||||
# Fallback to root for unknown contexts
|
||||
logger.debug("Unknown context, redirecting to /")
|
||||
return RedirectResponse(url="/", status_code=302)
|
||||
# Fallback to root for unknown contexts
|
||||
logger.debug("Unknown context, redirecting to /")
|
||||
return RedirectResponse(url="/", status_code=302)
|
||||
|
||||
|
||||
# Utility functions for common exception scenarios
|
||||
|
||||
Reference in New Issue
Block a user