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:
@@ -6,20 +6,20 @@ This module contains the canonical implementations of monitoring-related service
|
||||
"""
|
||||
|
||||
from app.modules.monitoring.services.admin_audit_service import (
|
||||
admin_audit_service,
|
||||
AdminAuditService,
|
||||
admin_audit_service,
|
||||
)
|
||||
from app.modules.monitoring.services.background_tasks_service import (
|
||||
background_tasks_service,
|
||||
BackgroundTasksService,
|
||||
background_tasks_service,
|
||||
)
|
||||
from app.modules.monitoring.services.log_service import (
|
||||
log_service,
|
||||
LogService,
|
||||
log_service,
|
||||
)
|
||||
from app.modules.monitoring.services.platform_health_service import (
|
||||
platform_health_service,
|
||||
PlatformHealthService,
|
||||
platform_health_service,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -15,9 +15,11 @@ from sqlalchemy import and_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.tenancy.exceptions import AdminOperationException
|
||||
from app.modules.tenancy.models import AdminAuditLog
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.schemas.admin import AdminAuditLogFilters, AdminAuditLogResponse
|
||||
from app.modules.tenancy.models import AdminAuditLog, User
|
||||
from app.modules.tenancy.schemas.admin import (
|
||||
AdminAuditLogFilters,
|
||||
AdminAuditLogResponse,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.contracts.audit import AuditEvent, AuditProviderProtocol
|
||||
from app.modules.contracts.audit import AuditEvent
|
||||
from app.modules.tenancy.models import AdminAuditLog
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -9,9 +9,8 @@ from datetime import UTC, datetime
|
||||
from sqlalchemy import case, desc, func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.dev_tools.models import ArchitectureScan
|
||||
from app.modules.dev_tools.models import ArchitectureScan, TestRun
|
||||
from app.modules.marketplace.models import MarketplaceImportJob
|
||||
from app.modules.dev_tools.models import TestRun
|
||||
|
||||
|
||||
class BackgroundTasksService:
|
||||
|
||||
@@ -174,7 +174,7 @@ class LogService:
|
||||
.group_by(ApplicationLog.level)
|
||||
.all()
|
||||
)
|
||||
by_level = {level: count for level, count in by_level_raw}
|
||||
by_level = dict(by_level_raw)
|
||||
|
||||
# Count by module (top 10)
|
||||
by_module_raw = (
|
||||
@@ -186,7 +186,7 @@ class LogService:
|
||||
.limit(10)
|
||||
.all()
|
||||
)
|
||||
by_module = {module: count for module, count in by_module_raw}
|
||||
by_module = dict(by_module_raw)
|
||||
|
||||
# Recent errors (last 5)
|
||||
recent_errors = (
|
||||
@@ -286,10 +286,7 @@ class LogService:
|
||||
try:
|
||||
# Determine log directory
|
||||
log_file_path = settings.log_file
|
||||
if log_file_path:
|
||||
log_dir = Path(log_file_path).parent
|
||||
else:
|
||||
log_dir = Path("logs")
|
||||
log_dir = Path(log_file_path).parent if log_file_path else Path("logs")
|
||||
|
||||
if not log_dir.exists():
|
||||
return []
|
||||
|
||||
@@ -16,10 +16,10 @@ import psutil
|
||||
from sqlalchemy import func, text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.cms.services.media_service import media_service
|
||||
from app.modules.inventory.models import Inventory
|
||||
from app.modules.orders.models import Order
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.tenancy.models import Store
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -172,7 +172,7 @@ class PlatformHealthService:
|
||||
|
||||
Returns aggregated limits and current usage for capacity planning.
|
||||
"""
|
||||
from app.modules.billing.models import MerchantSubscription, TierFeatureLimit
|
||||
from app.modules.billing.models import MerchantSubscription
|
||||
from app.modules.tenancy.models import StoreUser
|
||||
|
||||
# Get all active subscriptions with tier + feature limits
|
||||
@@ -247,7 +247,7 @@ class PlatformHealthService:
|
||||
"utilization_percent": None,
|
||||
"has_unlimited": True,
|
||||
}
|
||||
elif limit > 0:
|
||||
if limit > 0:
|
||||
return {
|
||||
"actual": actual,
|
||||
"theoretical_limit": limit,
|
||||
@@ -256,14 +256,13 @@ class PlatformHealthService:
|
||||
"headroom": limit - actual,
|
||||
"has_unlimited": False,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"actual": actual,
|
||||
"theoretical_limit": 0,
|
||||
"unlimited_count": 0,
|
||||
"utilization_percent": 0,
|
||||
"has_unlimited": False,
|
||||
}
|
||||
return {
|
||||
"actual": actual,
|
||||
"theoretical_limit": 0,
|
||||
"unlimited_count": 0,
|
||||
"utilization_percent": 0,
|
||||
"has_unlimited": False,
|
||||
}
|
||||
|
||||
return {
|
||||
"total_subscriptions": len(subscriptions),
|
||||
@@ -527,10 +526,9 @@ class PlatformHealthService:
|
||||
|
||||
if "critical" in statuses:
|
||||
return "critical"
|
||||
elif "warning" in statuses:
|
||||
if "warning" in statuses:
|
||||
return "degraded"
|
||||
else:
|
||||
return "healthy"
|
||||
return "healthy"
|
||||
|
||||
|
||||
# Create service instance
|
||||
|
||||
Reference in New Issue
Block a user