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:
@@ -42,6 +42,7 @@ sys.path.insert(0, str(project_root))
|
||||
# =============================================================================
|
||||
# MODE DETECTION (from environment variable set by Makefile)
|
||||
# =============================================================================
|
||||
import contextlib
|
||||
import os
|
||||
|
||||
from sqlalchemy import delete, select
|
||||
@@ -50,25 +51,33 @@ from sqlalchemy.orm import Session
|
||||
from app.core.config import settings
|
||||
from app.core.database import SessionLocal
|
||||
from app.core.environment import get_environment, is_production
|
||||
from middleware.auth import AuthManager
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.cms.models import ContentPage, StoreTheme
|
||||
from app.modules.customers.models.customer import Customer, CustomerAddress
|
||||
from app.modules.marketplace.models import (
|
||||
MarketplaceImportJob,
|
||||
MarketplaceProduct,
|
||||
MarketplaceProductTranslation,
|
||||
)
|
||||
from app.modules.orders.models import Order, OrderItem
|
||||
|
||||
# =============================================================================
|
||||
# MODEL IMPORTS
|
||||
# =============================================================================
|
||||
# ALL models must be imported before any ORM query so SQLAlchemy can resolve
|
||||
# cross-module string relationships (e.g. Store→StoreEmailTemplate,
|
||||
# Platform→SubscriptionTier, Product→Inventory).
|
||||
|
||||
# Core modules
|
||||
from app.modules.tenancy.models import Merchant, PlatformAlert, User, Role, Store, StoreUser, StoreDomain
|
||||
from app.modules.cms.models import ContentPage, StoreTheme
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.customers.models.customer import Customer, CustomerAddress
|
||||
from app.modules.orders.models import Order, OrderItem
|
||||
from app.modules.marketplace.models import (
|
||||
MarketplaceImportJob,
|
||||
MarketplaceProduct,
|
||||
MarketplaceProductTranslation,
|
||||
from app.modules.tenancy.models import (
|
||||
Merchant,
|
||||
PlatformAlert,
|
||||
Role,
|
||||
Store,
|
||||
StoreDomain,
|
||||
StoreUser,
|
||||
User,
|
||||
)
|
||||
from middleware.auth import AuthManager
|
||||
|
||||
# Optional modules — import to register models with SQLAlchemy
|
||||
for _mod in [
|
||||
@@ -78,10 +87,8 @@ for _mod in [
|
||||
"app.modules.messaging.models",
|
||||
"app.modules.loyalty.models",
|
||||
]:
|
||||
try:
|
||||
with contextlib.suppress(ImportError):
|
||||
__import__(_mod)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
SEED_MODE = os.getenv("SEED_MODE", "normal") # normal, minimal, reset
|
||||
FORCE_RESET = os.getenv("FORCE_RESET", "false").lower() in ("true", "1", "yes")
|
||||
@@ -562,7 +569,7 @@ def reset_all_data(db: Session):
|
||||
for table in tables_to_clear:
|
||||
if table == ContentPage:
|
||||
# Only delete store content pages, keep platform defaults
|
||||
db.execute(delete(ContentPage).where(ContentPage.store_id != None))
|
||||
db.execute(delete(ContentPage).where(ContentPage.store_id is not None))
|
||||
else:
|
||||
db.execute(delete(table))
|
||||
|
||||
@@ -1104,8 +1111,8 @@ def print_summary(db: Session):
|
||||
team_member_count = db.query(StoreUser).filter(StoreUser.user_type == "member").count()
|
||||
customer_count = db.query(Customer).count()
|
||||
product_count = db.query(Product).count()
|
||||
platform_pages = db.query(ContentPage).filter(ContentPage.store_id == None).count()
|
||||
store_pages = db.query(ContentPage).filter(ContentPage.store_id != None).count()
|
||||
platform_pages = db.query(ContentPage).filter(ContentPage.store_id is None).count()
|
||||
store_pages = db.query(ContentPage).filter(ContentPage.store_id is not None).count()
|
||||
|
||||
print("\n📊 Database Status:")
|
||||
print(f" Merchants: {merchant_count}")
|
||||
|
||||
Reference in New Issue
Block a user