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:
@@ -3,17 +3,21 @@
|
||||
Team management specific exceptions.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any
|
||||
|
||||
from .base import (AuthorizationException, BusinessLogicException,
|
||||
ConflictException, ResourceNotFoundException,
|
||||
ValidationException)
|
||||
from .base import (
|
||||
AuthorizationException,
|
||||
BusinessLogicException,
|
||||
ConflictException,
|
||||
ResourceNotFoundException,
|
||||
ValidationException,
|
||||
)
|
||||
|
||||
|
||||
class TeamMemberNotFoundException(ResourceNotFoundException):
|
||||
"""Raised when a team member is not found."""
|
||||
|
||||
def __init__(self, user_id: int, vendor_id: Optional[int] = None):
|
||||
def __init__(self, user_id: int, vendor_id: int | None = None):
|
||||
details = {"user_id": user_id}
|
||||
if vendor_id:
|
||||
details["vendor_id"] = vendor_id
|
||||
@@ -63,7 +67,7 @@ class TeamInvitationExpiredException(BusinessLogicException):
|
||||
|
||||
def __init__(self, invitation_token: str):
|
||||
super().__init__(
|
||||
message=f"Team invitation has expired",
|
||||
message="Team invitation has expired",
|
||||
error_code="TEAM_INVITATION_EXPIRED",
|
||||
details={"invitation_token": invitation_token},
|
||||
)
|
||||
@@ -86,8 +90,8 @@ class UnauthorizedTeamActionException(AuthorizationException):
|
||||
def __init__(
|
||||
self,
|
||||
action: str,
|
||||
user_id: Optional[int] = None,
|
||||
required_permission: Optional[str] = None,
|
||||
user_id: int | None = None,
|
||||
required_permission: str | None = None,
|
||||
):
|
||||
details = {"action": action}
|
||||
if user_id:
|
||||
@@ -130,7 +134,7 @@ class CannotModifyOwnRoleException(BusinessLogicException):
|
||||
class RoleNotFoundException(ResourceNotFoundException):
|
||||
"""Raised when a role is not found."""
|
||||
|
||||
def __init__(self, role_id: int, vendor_id: Optional[int] = None):
|
||||
def __init__(self, role_id: int, vendor_id: int | None = None):
|
||||
details = {"role_id": role_id}
|
||||
if vendor_id:
|
||||
details["vendor_id"] = vendor_id
|
||||
@@ -153,8 +157,8 @@ class InvalidRoleException(ValidationException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Invalid role data",
|
||||
field: Optional[str] = None,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
field: str | None = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -170,8 +174,8 @@ class InsufficientTeamPermissionsException(AuthorizationException):
|
||||
def __init__(
|
||||
self,
|
||||
required_permission: str,
|
||||
user_id: Optional[int] = None,
|
||||
action: Optional[str] = None,
|
||||
user_id: int | None = None,
|
||||
action: str | None = None,
|
||||
):
|
||||
details = {"required_permission": required_permission}
|
||||
if user_id:
|
||||
@@ -208,8 +212,8 @@ class TeamValidationException(ValidationException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Team operation validation failed",
|
||||
field: Optional[str] = None,
|
||||
validation_errors: Optional[Dict[str, str]] = None,
|
||||
field: str | None = None,
|
||||
validation_errors: dict[str, str] | None = None,
|
||||
):
|
||||
details = {}
|
||||
if validation_errors:
|
||||
@@ -229,8 +233,8 @@ class InvalidInvitationDataException(ValidationException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Invalid invitation data",
|
||||
field: Optional[str] = None,
|
||||
details: Optional[Dict[str, Any]] = None,
|
||||
field: str | None = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
message=message,
|
||||
@@ -255,7 +259,7 @@ class InvalidInvitationTokenException(ValidationException):
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "Invalid or expired invitation token",
|
||||
invitation_token: Optional[str] = None,
|
||||
invitation_token: str | None = None,
|
||||
):
|
||||
details = {}
|
||||
if invitation_token:
|
||||
|
||||
Reference in New Issue
Block a user