fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,8 +17,8 @@ Storefront routes:
|
||||
"""
|
||||
|
||||
from app.modules.messaging.routes.api.admin import admin_router
|
||||
from app.modules.messaging.routes.api.storefront import router as storefront_router
|
||||
from app.modules.messaging.routes.api.store import store_router
|
||||
from app.modules.messaging.routes.api.storefront import router as storefront_router
|
||||
|
||||
# Tag for OpenAPI documentation
|
||||
STOREFRONT_TAG = "Messages (Storefront)"
|
||||
|
||||
@@ -13,9 +13,9 @@ from fastapi import APIRouter, Depends
|
||||
from app.api.deps import require_module_access
|
||||
from app.modules.enums import FrontendType
|
||||
|
||||
from .admin_email_templates import admin_email_templates_router
|
||||
from .admin_messages import admin_messages_router
|
||||
from .admin_notifications import admin_notifications_router
|
||||
from .admin_email_templates import admin_email_templates_router
|
||||
|
||||
admin_router = APIRouter(
|
||||
dependencies=[Depends(require_module_access("messaging", FrontendType.ADMIN))],
|
||||
|
||||
@@ -239,11 +239,10 @@ def send_test_email(
|
||||
"success": True,
|
||||
"message": f"Test email sent to {test_data.to_email}",
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"success": False,
|
||||
"message": email_log.error_message or "Failed to send email",
|
||||
}
|
||||
return {
|
||||
"success": False,
|
||||
"message": email_log.error_message or "Failed to send email",
|
||||
}
|
||||
except Exception as e:
|
||||
logger.exception(f"Failed to send test email: {e}")
|
||||
return {
|
||||
|
||||
@@ -25,8 +25,6 @@ from app.modules.messaging.exceptions import (
|
||||
InvalidRecipientTypeException,
|
||||
MessageAttachmentException,
|
||||
)
|
||||
from app.modules.messaging.services.message_attachment_service import message_attachment_service
|
||||
from app.modules.messaging.services.messaging_service import messaging_service
|
||||
from app.modules.messaging.models import ConversationType, ParticipantType
|
||||
from app.modules.messaging.schemas import (
|
||||
AdminConversationListResponse,
|
||||
@@ -36,7 +34,6 @@ from app.modules.messaging.schemas import (
|
||||
ConversationCreate,
|
||||
ConversationDetailResponse,
|
||||
MarkReadResponse,
|
||||
MessageCreate,
|
||||
MessageResponse,
|
||||
NotificationPreferencesUpdate,
|
||||
ParticipantInfo,
|
||||
@@ -46,6 +43,10 @@ from app.modules.messaging.schemas import (
|
||||
ReopenConversationResponse,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from app.modules.messaging.services.message_attachment_service import (
|
||||
message_attachment_service,
|
||||
)
|
||||
from app.modules.messaging.services.messaging_service import messaging_service
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
admin_messages_router = APIRouter(prefix="/messages")
|
||||
|
||||
@@ -15,11 +15,15 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_admin_api
|
||||
from app.core.database import get_db
|
||||
from app.modules.messaging.schemas import (
|
||||
AlertStatisticsResponse,
|
||||
MessageResponse,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from app.modules.messaging.services.admin_notification_service import (
|
||||
admin_notification_service,
|
||||
platform_alert_service,
|
||||
)
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.tenancy.schemas.admin import (
|
||||
AdminNotificationCreate,
|
||||
AdminNotificationListResponse,
|
||||
@@ -29,11 +33,7 @@ from app.modules.tenancy.schemas.admin import (
|
||||
PlatformAlertResolve,
|
||||
PlatformAlertResponse,
|
||||
)
|
||||
from app.modules.messaging.schemas import (
|
||||
AlertStatisticsResponse,
|
||||
MessageResponse,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
admin_notifications_router = APIRouter(prefix="/notifications")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -14,10 +14,10 @@ from fastapi import APIRouter, Depends
|
||||
from app.api.deps import require_module_access
|
||||
from app.modules.enums import FrontendType
|
||||
|
||||
from .store_messages import store_messages_router
|
||||
from .store_notifications import store_notifications_router
|
||||
from .store_email_settings import store_email_settings_router
|
||||
from .store_email_templates import store_email_templates_router
|
||||
from .store_messages import store_messages_router
|
||||
from .store_notifications import store_notifications_router
|
||||
|
||||
store_router = APIRouter(
|
||||
dependencies=[Depends(require_module_access("messaging", FrontendType.STORE))],
|
||||
|
||||
@@ -20,8 +20,10 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_store_api
|
||||
from app.core.database import get_db
|
||||
from app.modules.cms.services.store_email_settings_service import store_email_settings_service
|
||||
from app.modules.billing.services.subscription_service import subscription_service
|
||||
from app.modules.cms.services.store_email_settings_service import (
|
||||
store_email_settings_service,
|
||||
)
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
store_email_settings_router = APIRouter(prefix="/email-settings")
|
||||
|
||||
@@ -236,11 +236,10 @@ def send_test_email(
|
||||
"success": True,
|
||||
"message": f"Test email sent to {test_data.to_email}",
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"success": False,
|
||||
"message": email_log.error_message or "Failed to send email",
|
||||
}
|
||||
return {
|
||||
"success": False,
|
||||
"message": email_log.error_message or "Failed to send email",
|
||||
}
|
||||
except Exception as e:
|
||||
logger.exception(f"Failed to send test email: {e}")
|
||||
return {
|
||||
|
||||
@@ -27,8 +27,6 @@ from app.modules.messaging.exceptions import (
|
||||
InvalidRecipientTypeException,
|
||||
MessageAttachmentException,
|
||||
)
|
||||
from app.modules.messaging.services.message_attachment_service import message_attachment_service
|
||||
from app.modules.messaging.services.messaging_service import messaging_service
|
||||
from app.modules.messaging.models import ConversationType, ParticipantType
|
||||
from app.modules.messaging.schemas import (
|
||||
AttachmentResponse,
|
||||
@@ -47,6 +45,10 @@ from app.modules.messaging.schemas import (
|
||||
ReopenConversationResponse,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from app.modules.messaging.services.message_attachment_service import (
|
||||
message_attachment_service,
|
||||
)
|
||||
from app.modules.messaging.services.messaging_service import messaging_service
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
store_messages_router = APIRouter(prefix="/messages")
|
||||
|
||||
@@ -13,8 +13,6 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_store_api
|
||||
from app.core.database import get_db
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
from models.schema.auth import UserContext
|
||||
from app.modules.messaging.schemas import (
|
||||
MessageResponse,
|
||||
NotificationListResponse,
|
||||
@@ -25,6 +23,8 @@ from app.modules.messaging.schemas import (
|
||||
TestNotificationRequest,
|
||||
UnreadCountResponse,
|
||||
)
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
store_notifications_router = APIRouter(prefix="/notifications")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -18,7 +18,6 @@ Customers can only:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, File, Form, Path, Query, Request, UploadFile
|
||||
from fastapi.responses import FileResponse
|
||||
@@ -27,13 +26,12 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_customer_api
|
||||
from app.core.database import get_db
|
||||
from app.modules.customers.schemas import CustomerContext
|
||||
from app.modules.messaging.exceptions import (
|
||||
AttachmentNotFoundException,
|
||||
ConversationClosedException,
|
||||
ConversationNotFoundException,
|
||||
)
|
||||
from app.modules.tenancy.exceptions import StoreNotFoundException
|
||||
from app.modules.customers.schemas import CustomerContext
|
||||
from app.modules.messaging.models.message import ConversationType, ParticipantType
|
||||
from app.modules.messaging.schemas import (
|
||||
ConversationDetailResponse,
|
||||
@@ -46,6 +44,7 @@ from app.modules.messaging.services import (
|
||||
message_attachment_service,
|
||||
messaging_service,
|
||||
)
|
||||
from app.modules.tenancy.exceptions import StoreNotFoundException
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -73,7 +72,7 @@ def list_conversations(
|
||||
request: Request,
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(50, ge=1, le=100),
|
||||
status: Optional[str] = Query(None, pattern="^(open|closed)$"),
|
||||
status: str | None = Query(None, pattern="^(open|closed)$"),
|
||||
customer: CustomerContext = Depends(get_current_customer_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -260,7 +259,7 @@ async def send_message(
|
||||
request: Request,
|
||||
conversation_id: int = Path(..., description="Conversation ID", gt=0),
|
||||
content: str = Form(..., min_length=1, max_length=10000),
|
||||
attachments: List[UploadFile] = File(default=[]),
|
||||
attachments: list[UploadFile] = File(default=[]),
|
||||
customer: CustomerContext = Depends(get_current_customer_api),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -513,7 +512,7 @@ def _get_sender_name(message) -> str:
|
||||
if customer:
|
||||
return f"{customer.first_name} {customer.last_name}"
|
||||
return "Customer"
|
||||
elif message.sender_type == ParticipantType.STORE:
|
||||
if message.sender_type == ParticipantType.STORE:
|
||||
from app.modules.tenancy.models import User
|
||||
|
||||
user = (
|
||||
@@ -524,6 +523,6 @@ def _get_sender_name(message) -> str:
|
||||
if user:
|
||||
return f"{user.first_name} {user.last_name}"
|
||||
return "Shop Support"
|
||||
elif message.sender_type == ParticipantType.ADMIN:
|
||||
if message.sender_type == ParticipantType.ADMIN:
|
||||
return "Platform Support"
|
||||
return "Unknown"
|
||||
|
||||
Reference in New Issue
Block a user