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:
@@ -8,7 +8,7 @@ This module provides classes and functions for:
|
||||
- Standardized error response structure
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any
|
||||
|
||||
|
||||
class WizamartException(Exception):
|
||||
@@ -19,7 +19,7 @@ class WizamartException(Exception):
|
||||
message: str,
|
||||
error_code: str,
|
||||
status_code: int = 400,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
self.message = message
|
||||
self.error_code = error_code
|
||||
@@ -27,7 +27,7 @@ class WizamartException(Exception):
|
||||
self.details = details or {}
|
||||
super().__init__(self.message)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
"""Convert exception to dictionary for JSON response."""
|
||||
result = {
|
||||
"error_code": self.error_code,
|
||||
@@ -45,8 +45,8 @@ class ValidationException(WizamartException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str,
|
||||
field: Optional[str] = None,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
field: str | None = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
validation_details = details or {}
|
||||
if field:
|
||||
@@ -67,7 +67,7 @@ class AuthenticationException(WizamartException):
|
||||
self,
|
||||
message: str = "Authentication failed",
|
||||
error_code: str = "AUTHENTICATION_FAILED",
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -84,7 +84,7 @@ class AuthorizationException(WizamartException):
|
||||
self,
|
||||
message: str = "Access denied",
|
||||
error_code: str = "AUTHORIZATION_FAILED",
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -101,8 +101,8 @@ class ResourceNotFoundException(WizamartException):
|
||||
self,
|
||||
resource_type: str,
|
||||
identifier: str,
|
||||
message: Optional[str] = None,
|
||||
error_code: Optional[str] = None,
|
||||
message: str | None = None,
|
||||
error_code: str | None = None,
|
||||
):
|
||||
if not message:
|
||||
message = f"{resource_type} with identifier '{identifier}' not found"
|
||||
@@ -127,7 +127,7 @@ class ConflictException(WizamartException):
|
||||
self,
|
||||
message: str,
|
||||
error_code: str = "RESOURCE_CONFLICT",
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -144,7 +144,7 @@ class BusinessLogicException(WizamartException):
|
||||
self,
|
||||
message: str,
|
||||
error_code: str,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -162,7 +162,7 @@ class ExternalServiceException(WizamartException):
|
||||
message: str,
|
||||
service_name: str,
|
||||
error_code: str = "EXTERNAL_SERVICE_ERROR",
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
service_details = details or {}
|
||||
service_details["service_name"] = service_name
|
||||
@@ -181,8 +181,8 @@ class RateLimitException(WizamartException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Rate limit exceeded",
|
||||
retry_after: Optional[int] = None,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
retry_after: int | None = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
rate_limit_details = details or {}
|
||||
if retry_after:
|
||||
|
||||
Reference in New Issue
Block a user