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:
@@ -10,8 +10,8 @@ Provides REST API endpoints for:
|
||||
"""
|
||||
|
||||
from app.modules.loyalty.routes.api.admin import admin_router
|
||||
from app.modules.loyalty.routes.api.store import store_router
|
||||
from app.modules.loyalty.routes.api.platform import platform_router
|
||||
from app.modules.loyalty.routes.api.store import store_router
|
||||
from app.modules.loyalty.routes.api.storefront import storefront_router
|
||||
|
||||
__all__ = ["admin_router", "store_router", "platform_router", "storefront_router"]
|
||||
|
||||
@@ -17,12 +17,12 @@ from app.api.deps import get_current_admin_api, require_module_access
|
||||
from app.core.database import get_db
|
||||
from app.modules.enums import FrontendType
|
||||
from app.modules.loyalty.schemas import (
|
||||
MerchantSettingsResponse,
|
||||
MerchantSettingsUpdate,
|
||||
MerchantStatsResponse,
|
||||
ProgramListResponse,
|
||||
ProgramResponse,
|
||||
ProgramStatsResponse,
|
||||
MerchantStatsResponse,
|
||||
MerchantSettingsResponse,
|
||||
MerchantSettingsUpdate,
|
||||
)
|
||||
from app.modules.loyalty.services import program_service
|
||||
from app.modules.tenancy.models import User
|
||||
@@ -182,7 +182,6 @@ def update_merchant_settings(
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""Update merchant loyalty settings (admin only)."""
|
||||
from app.modules.loyalty.models import MerchantLoyaltySettings
|
||||
|
||||
settings = program_service.get_or_create_merchant_settings(db, merchant_id)
|
||||
|
||||
@@ -211,7 +210,11 @@ def get_platform_stats(
|
||||
"""Get platform-wide loyalty statistics."""
|
||||
from sqlalchemy import func
|
||||
|
||||
from app.modules.loyalty.models import LoyaltyCard, LoyaltyProgram, LoyaltyTransaction
|
||||
from app.modules.loyalty.models import (
|
||||
LoyaltyCard,
|
||||
LoyaltyProgram,
|
||||
LoyaltyTransaction,
|
||||
)
|
||||
|
||||
# Program counts
|
||||
total_programs = db.query(func.count(LoyaltyProgram.id)).scalar() or 0
|
||||
|
||||
@@ -9,21 +9,18 @@ Platform endpoints for:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import UTC, datetime
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, Header, HTTPException, Path, Response
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.modules.loyalty.exceptions import (
|
||||
LoyaltyCardNotFoundException,
|
||||
LoyaltyException,
|
||||
LoyaltyProgramNotFoundException,
|
||||
)
|
||||
from app.modules.loyalty.models import LoyaltyCard, LoyaltyProgram
|
||||
from app.modules.loyalty.models import LoyaltyCard
|
||||
from app.modules.loyalty.services import (
|
||||
apple_wallet_service,
|
||||
card_service,
|
||||
program_service,
|
||||
)
|
||||
|
||||
|
||||
@@ -20,34 +20,33 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_store_api, require_module_access
|
||||
from app.core.database import get_db
|
||||
from app.modules.enums import FrontendType
|
||||
from app.modules.loyalty.exceptions import (
|
||||
LoyaltyCardNotFoundException,
|
||||
LoyaltyException,
|
||||
LoyaltyProgramNotFoundException,
|
||||
)
|
||||
from app.modules.loyalty.schemas import (
|
||||
CardDetailResponse,
|
||||
CardEnrollRequest,
|
||||
CardListResponse,
|
||||
CardLookupResponse,
|
||||
CardResponse,
|
||||
MerchantStatsResponse,
|
||||
PinCreate,
|
||||
PinListResponse,
|
||||
PinResponse,
|
||||
PinUpdate,
|
||||
PointsAdjustRequest,
|
||||
PointsAdjustResponse,
|
||||
PointsEarnRequest,
|
||||
PointsEarnResponse,
|
||||
PointsRedeemRequest,
|
||||
PointsRedeemResponse,
|
||||
PointsVoidRequest,
|
||||
PointsVoidResponse,
|
||||
PointsAdjustRequest,
|
||||
PointsAdjustResponse,
|
||||
ProgramCreate,
|
||||
ProgramResponse,
|
||||
ProgramStatsResponse,
|
||||
ProgramUpdate,
|
||||
MerchantStatsResponse,
|
||||
StampRedeemRequest,
|
||||
StampRedeemResponse,
|
||||
StampRequest,
|
||||
@@ -63,10 +62,8 @@ from app.modules.loyalty.services import (
|
||||
points_service,
|
||||
program_service,
|
||||
stamp_service,
|
||||
wallet_service,
|
||||
)
|
||||
from app.modules.enums import FrontendType
|
||||
from app.modules.tenancy.models import User, Store
|
||||
from app.modules.tenancy.models import Store, User
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -466,7 +463,7 @@ def get_card_transactions(
|
||||
|
||||
# Verify card belongs to this merchant
|
||||
try:
|
||||
card = card_service.lookup_card_for_store(db, store_id, card_id=card_id)
|
||||
card_service.lookup_card_for_store(db, store_id, card_id=card_id)
|
||||
except LoyaltyCardNotFoundException:
|
||||
raise HTTPException(status_code=404, detail="Card not found")
|
||||
|
||||
|
||||
@@ -19,14 +19,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.loyalty.services import card_service, program_service
|
||||
from app.modules.loyalty.schemas import (
|
||||
CardResponse,
|
||||
CardEnrollRequest,
|
||||
TransactionListResponse,
|
||||
TransactionResponse,
|
||||
CardResponse,
|
||||
ProgramResponse,
|
||||
)
|
||||
from app.modules.loyalty.services import card_service, program_service
|
||||
from app.modules.tenancy.exceptions import StoreNotFoundException
|
||||
|
||||
storefront_router = APIRouter()
|
||||
@@ -212,7 +210,7 @@ def get_my_transactions(
|
||||
for tx in transactions:
|
||||
tx_data = {
|
||||
"id": tx.id,
|
||||
"transaction_type": tx.transaction_type.value if hasattr(tx.transaction_type, 'value') else str(tx.transaction_type),
|
||||
"transaction_type": tx.transaction_type.value if hasattr(tx.transaction_type, "value") else str(tx.transaction_type),
|
||||
"points_delta": tx.points_delta,
|
||||
"stamps_delta": tx.stamps_delta,
|
||||
"points_balance_after": tx.points_balance_after,
|
||||
|
||||
Reference in New Issue
Block a user