fix(lint): pin ruff version, add pre-commit hook, fix all lint errors
Some checks failed
Some checks failed
- Pin ruff==0.8.4 in requirements-dev.txt (was >=0.8.4, CI got newer version with different import sorting rules) - Add ruff to .pre-commit-config.yaml with --fix to auto-sort imports on commit (prevents PyCharm import reordering from reaching CI) - Fix I001 import sorting in 6 files - Fix F401 unused import (sqlalchemy.Numeric in subscription.py) - Fix noqa false positive in validate_architecture.py comment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,15 +29,9 @@ repos:
|
|||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
|
|
||||||
# Python formatting (optional - uncomment if you want)
|
# Ruff - linting and import sorting (replaces black + isort)
|
||||||
# - repo: https://github.com/psf/black
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
# rev: 23.12.1
|
rev: v0.8.4
|
||||||
# hooks:
|
hooks:
|
||||||
# - id: black
|
- id: ruff
|
||||||
# language_version: python3
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
||||||
# Python import sorting (optional)
|
|
||||||
# - repo: https://github.com/pycqa/isort
|
|
||||||
# rev: 5.13.2
|
|
||||||
# hooks:
|
|
||||||
# - id: isort
|
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ from sqlalchemy.orm import Session
|
|||||||
from app.modules.catalog.models import Product # IMPORT-002
|
from app.modules.catalog.models import Product # IMPORT-002
|
||||||
from app.modules.customers.models.customer import Customer # IMPORT-002
|
from app.modules.customers.models.customer import Customer # IMPORT-002
|
||||||
from app.modules.inventory.models import Inventory # IMPORT-002
|
from app.modules.inventory.models import Inventory # IMPORT-002
|
||||||
from app.modules.marketplace.models import MarketplaceImportJob, MarketplaceProduct # IMPORT-002
|
from app.modules.marketplace.models import ( # IMPORT-002
|
||||||
|
MarketplaceImportJob,
|
||||||
|
MarketplaceProduct,
|
||||||
|
)
|
||||||
from app.modules.orders.models import Order # IMPORT-002
|
from app.modules.orders.models import Order # IMPORT-002
|
||||||
from app.modules.tenancy.exceptions import (
|
from app.modules.tenancy.exceptions import (
|
||||||
AdminOperationException,
|
AdminOperationException,
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from sqlalchemy import (
|
|||||||
ForeignKey,
|
ForeignKey,
|
||||||
Index,
|
Index,
|
||||||
Integer,
|
Integer,
|
||||||
Numeric,
|
|
||||||
String,
|
String,
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ from app.modules.billing.schemas.billing import (
|
|||||||
CancelRequest,
|
CancelRequest,
|
||||||
CancelResponse,
|
CancelResponse,
|
||||||
CategoryListResponse,
|
CategoryListResponse,
|
||||||
ChangeTierRequest as BillingChangeTierRequest,
|
|
||||||
ChangeTierResponse as BillingChangeTierResponse,
|
|
||||||
# Checkout & Portal schemas
|
# Checkout & Portal schemas
|
||||||
CheckoutRequest,
|
CheckoutRequest,
|
||||||
CheckoutResponse,
|
CheckoutResponse,
|
||||||
@@ -56,12 +54,18 @@ from app.modules.billing.schemas.billing import (
|
|||||||
SubscriptionTierListResponse,
|
SubscriptionTierListResponse,
|
||||||
SubscriptionTierResponse,
|
SubscriptionTierResponse,
|
||||||
SubscriptionTierUpdate,
|
SubscriptionTierUpdate,
|
||||||
TierListResponse,
|
|
||||||
TierResponse,
|
|
||||||
# Subscription Tier Admin schemas
|
# Subscription Tier Admin schemas
|
||||||
TierFeatureLimitEntry,
|
TierFeatureLimitEntry,
|
||||||
|
TierListResponse,
|
||||||
|
TierResponse,
|
||||||
UpcomingInvoiceResponse,
|
UpcomingInvoiceResponse,
|
||||||
)
|
)
|
||||||
|
from app.modules.billing.schemas.billing import (
|
||||||
|
ChangeTierRequest as BillingChangeTierRequest,
|
||||||
|
)
|
||||||
|
from app.modules.billing.schemas.billing import (
|
||||||
|
ChangeTierResponse as BillingChangeTierResponse,
|
||||||
|
)
|
||||||
from app.modules.billing.schemas.subscription import (
|
from app.modules.billing.schemas.subscription import (
|
||||||
ChangeTierRequest,
|
ChangeTierRequest,
|
||||||
ChangeTierResponse,
|
ChangeTierResponse,
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ from app.modules.messaging.exceptions import (
|
|||||||
ConversationClosedException,
|
ConversationClosedException,
|
||||||
ConversationNotFoundException,
|
ConversationNotFoundException,
|
||||||
)
|
)
|
||||||
from app.modules.messaging.models.message import ConversationType, ParticipantType # API-007
|
from app.modules.messaging.models.message import ( # API-007
|
||||||
|
ConversationType,
|
||||||
|
ParticipantType,
|
||||||
|
)
|
||||||
from app.modules.messaging.schemas import (
|
from app.modules.messaging.schemas import (
|
||||||
ConversationDetailResponse,
|
ConversationDetailResponse,
|
||||||
ConversationListResponse,
|
ConversationListResponse,
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ Monitoring module database models.
|
|||||||
Provides monitoring-related models including capacity snapshots.
|
Provides monitoring-related models including capacity snapshots.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from app.modules.monitoring.models.capacity_snapshot import CapacitySnapshot
|
|
||||||
|
|
||||||
# Admin notification and logging models
|
# Admin notification and logging models
|
||||||
from app.modules.messaging.models import AdminNotification
|
from app.modules.messaging.models import AdminNotification
|
||||||
|
from app.modules.monitoring.models.capacity_snapshot import CapacitySnapshot
|
||||||
from app.modules.tenancy.models import PlatformAlert
|
from app.modules.tenancy.models import PlatformAlert
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ from app.modules.monitoring.services.admin_audit_service import (
|
|||||||
AdminAuditService,
|
AdminAuditService,
|
||||||
admin_audit_service,
|
admin_audit_service,
|
||||||
)
|
)
|
||||||
from app.modules.monitoring.services.capacity_forecast_service import (
|
|
||||||
CapacityForecastService,
|
|
||||||
capacity_forecast_service,
|
|
||||||
)
|
|
||||||
from app.modules.monitoring.services.background_tasks_service import (
|
from app.modules.monitoring.services.background_tasks_service import (
|
||||||
BackgroundTasksService,
|
BackgroundTasksService,
|
||||||
background_tasks_service,
|
background_tasks_service,
|
||||||
)
|
)
|
||||||
|
from app.modules.monitoring.services.capacity_forecast_service import (
|
||||||
|
CapacityForecastService,
|
||||||
|
capacity_forecast_service,
|
||||||
|
)
|
||||||
from app.modules.monitoring.services.log_service import (
|
from app.modules.monitoring.services.log_service import (
|
||||||
LogService,
|
LogService,
|
||||||
log_service,
|
log_service,
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -26,11 +26,11 @@ from fastapi import Depends, FastAPI, HTTPException, Request, Response
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import FileResponse, HTMLResponse, RedirectResponse
|
from fastapi.responses import FileResponse, HTMLResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
|
|
||||||
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
||||||
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
|
||||||
|
|
||||||
from app.api.main import api_router
|
from app.api.main import api_router
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ alembic>=1.14.0
|
|||||||
# Linting and formatting tools
|
# Linting and formatting tools
|
||||||
black>=24.10.0
|
black>=24.10.0
|
||||||
isort>=5.13.2
|
isort>=5.13.2
|
||||||
ruff>=0.8.4 # Modern alternative to flake8, faster and Python 3.13 compatible
|
ruff==0.8.4 # Pinned — must match pre-commit hook and local version
|
||||||
mypy>=1.13.0
|
mypy>=1.13.0
|
||||||
|
|
||||||
# Optional: More advanced linting (if you prefer flake8 over ruff)
|
# Optional: More advanced linting (if you prefer flake8 over ruff)
|
||||||
|
|||||||
@@ -4663,7 +4663,7 @@ class ArchitectureValidator:
|
|||||||
if imported_module == module_name:
|
if imported_module == module_name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip suppression comments (# IMPORT-002 or # noqa: import-002)
|
# Skip suppression comments (# IMPORT-002)
|
||||||
if "import-002" in line.lower():
|
if "import-002" in line.lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ from main import app
|
|||||||
from tests.integration.middleware.middleware_test_routes import (
|
from tests.integration.middleware.middleware_test_routes import (
|
||||||
admin_router,
|
admin_router,
|
||||||
api_router,
|
api_router,
|
||||||
storefront_router,
|
|
||||||
store_router,
|
store_router,
|
||||||
|
storefront_router,
|
||||||
)
|
)
|
||||||
from tests.integration.middleware.middleware_test_routes import (
|
from tests.integration.middleware.middleware_test_routes import (
|
||||||
router as test_router,
|
router as test_router,
|
||||||
|
|||||||
Reference in New Issue
Block a user