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:
@@ -20,13 +20,15 @@ from app.modules.tenancy.services.admin_platform_service import (
|
||||
admin_platform_service,
|
||||
)
|
||||
from app.modules.tenancy.services.admin_service import AdminService, admin_service
|
||||
from app.modules.tenancy.services.merchant_service import MerchantService, merchant_service
|
||||
from app.modules.tenancy.services.merchant_service import (
|
||||
MerchantService,
|
||||
merchant_service,
|
||||
)
|
||||
from app.modules.tenancy.services.platform_service import (
|
||||
PlatformService,
|
||||
PlatformStats,
|
||||
platform_service,
|
||||
)
|
||||
from app.modules.tenancy.services.team_service import TeamService, team_service
|
||||
from app.modules.tenancy.services.store_domain_service import (
|
||||
StoreDomainService,
|
||||
store_domain_service,
|
||||
@@ -36,6 +38,7 @@ from app.modules.tenancy.services.store_team_service import (
|
||||
StoreTeamService,
|
||||
store_team_service,
|
||||
)
|
||||
from app.modules.tenancy.services.team_service import TeamService, team_service
|
||||
|
||||
__all__ = [
|
||||
# Store
|
||||
|
||||
@@ -20,9 +20,7 @@ from app.modules.tenancy.exceptions import (
|
||||
AdminOperationException,
|
||||
CannotModifySelfException,
|
||||
)
|
||||
from app.modules.tenancy.models import AdminPlatform
|
||||
from app.modules.tenancy.models import Platform
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.models import AdminPlatform, Platform, User
|
||||
from models.schema.auth import UserContext
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -344,7 +342,6 @@ class AdminPlatformService:
|
||||
field="user_id",
|
||||
)
|
||||
|
||||
old_status = user.is_super_admin
|
||||
user.is_super_admin = is_super_admin
|
||||
user.updated_at = datetime.now(UTC)
|
||||
db.flush()
|
||||
|
||||
@@ -23,21 +23,18 @@ from app.exceptions import ValidationException
|
||||
from app.modules.tenancy.exceptions import (
|
||||
AdminOperationException,
|
||||
CannotModifySelfException,
|
||||
StoreAlreadyExistsException,
|
||||
StoreNotFoundException,
|
||||
StoreVerificationException,
|
||||
UserAlreadyExistsException,
|
||||
UserCannotBeDeletedException,
|
||||
UserNotFoundException,
|
||||
UserRoleChangeException,
|
||||
UserStatusChangeException,
|
||||
StoreAlreadyExistsException,
|
||||
StoreNotFoundException,
|
||||
StoreVerificationException,
|
||||
)
|
||||
from middleware.auth import AuthManager
|
||||
from app.modules.tenancy.models import Merchant
|
||||
from app.modules.tenancy.models import Platform
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.models import Role, Store
|
||||
from app.modules.tenancy.models import Merchant, Platform, Role, Store, User
|
||||
from app.modules.tenancy.schemas.store import StoreCreate
|
||||
from middleware.auth import AuthManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -564,7 +561,6 @@ class AdminService:
|
||||
store = self._get_store_by_id_or_raise(db, store_id)
|
||||
|
||||
try:
|
||||
original_status = store.is_active
|
||||
store.is_active = not store.is_active
|
||||
store.updated_at = datetime.now(UTC)
|
||||
db.flush()
|
||||
|
||||
@@ -80,7 +80,7 @@ class MerchantDomainService:
|
||||
"""
|
||||
try:
|
||||
# Verify merchant exists
|
||||
merchant = self._get_merchant_by_id_or_raise(db, merchant_id)
|
||||
self._get_merchant_by_id_or_raise(db, merchant_id)
|
||||
|
||||
# Check domain limit
|
||||
self._check_domain_limit(db, merchant_id)
|
||||
|
||||
@@ -12,10 +12,16 @@ import string
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
|
||||
from app.modules.tenancy.exceptions import MerchantNotFoundException, UserNotFoundException
|
||||
from app.modules.tenancy.models import Merchant
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.schemas.merchant import MerchantCreate, MerchantTransferOwnership, MerchantUpdate
|
||||
from app.modules.tenancy.exceptions import (
|
||||
MerchantNotFoundException,
|
||||
UserNotFoundException,
|
||||
)
|
||||
from app.modules.tenancy.models import Merchant, Store, User
|
||||
from app.modules.tenancy.schemas.merchant import (
|
||||
MerchantCreate,
|
||||
MerchantTransferOwnership,
|
||||
MerchantUpdate,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -320,6 +326,15 @@ class MerchantService:
|
||||
|
||||
return merchant, old_owner, new_owner
|
||||
|
||||
def get_merchant_stores(
|
||||
self, db: Session, merchant_id: int, skip: int = 0, limit: int = 100
|
||||
) -> tuple[list, int]:
|
||||
"""Get paginated stores for a merchant."""
|
||||
query = db.query(Store).filter(Store.merchant_id == merchant_id)
|
||||
total = query.count()
|
||||
stores = query.order_by(Store.id).offset(skip).limit(limit).all()
|
||||
return stores, total
|
||||
|
||||
def _generate_temp_password(self, length: int = 12) -> str:
|
||||
"""Generate secure temporary password."""
|
||||
alphabet = string.ascii_letters + string.digits + "!@#$%^&*"
|
||||
|
||||
@@ -32,8 +32,6 @@ Usage:
|
||||
import logging
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from app.modules.base import PermissionDefinition
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -17,12 +17,11 @@ from dataclasses import dataclass
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.cms.models import ContentPage
|
||||
from app.modules.tenancy.exceptions import (
|
||||
PlatformNotFoundException,
|
||||
)
|
||||
from app.modules.cms.models import ContentPage
|
||||
from app.modules.tenancy.models import Platform
|
||||
from app.modules.tenancy.models import StorePlatform
|
||||
from app.modules.tenancy.models import Platform, StorePlatform
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -159,7 +158,7 @@ class PlatformService:
|
||||
db.query(func.count(ContentPage.id))
|
||||
.filter(
|
||||
ContentPage.platform_id == platform_id,
|
||||
ContentPage.store_id == None,
|
||||
ContentPage.store_id is None,
|
||||
ContentPage.is_platform_page == True,
|
||||
)
|
||||
.scalar()
|
||||
@@ -182,7 +181,7 @@ class PlatformService:
|
||||
db.query(func.count(ContentPage.id))
|
||||
.filter(
|
||||
ContentPage.platform_id == platform_id,
|
||||
ContentPage.store_id == None,
|
||||
ContentPage.store_id is None,
|
||||
ContentPage.is_platform_page == False,
|
||||
)
|
||||
.scalar()
|
||||
@@ -205,7 +204,7 @@ class PlatformService:
|
||||
db.query(func.count(ContentPage.id))
|
||||
.filter(
|
||||
ContentPage.platform_id == platform_id,
|
||||
ContentPage.store_id != None,
|
||||
ContentPage.store_id is not None,
|
||||
)
|
||||
.scalar()
|
||||
or 0
|
||||
|
||||
@@ -29,9 +29,11 @@ from app.modules.tenancy.exceptions import (
|
||||
StoreDomainNotFoundException,
|
||||
StoreNotFoundException,
|
||||
)
|
||||
from app.modules.tenancy.models import Store
|
||||
from app.modules.tenancy.models import StoreDomain
|
||||
from app.modules.tenancy.schemas.store_domain import StoreDomainCreate, StoreDomainUpdate
|
||||
from app.modules.tenancy.models import Store, StoreDomain
|
||||
from app.modules.tenancy.schemas.store_domain import (
|
||||
StoreDomainCreate,
|
||||
StoreDomainUpdate,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -74,7 +76,7 @@ class StoreDomainService:
|
||||
"""
|
||||
try:
|
||||
# Verify store exists
|
||||
store = self._get_store_by_id_or_raise(db, store_id)
|
||||
self._get_store_by_id_or_raise(db, store_id)
|
||||
|
||||
# Check domain limit
|
||||
self._check_domain_limit(db, store_id)
|
||||
|
||||
@@ -18,12 +18,11 @@ from sqlalchemy.orm import Session
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.tenancy.exceptions import (
|
||||
InvalidStoreDataException,
|
||||
UnauthorizedStoreAccessException,
|
||||
StoreAlreadyExistsException,
|
||||
StoreNotFoundException,
|
||||
UnauthorizedStoreAccessException,
|
||||
)
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.models import Store
|
||||
from app.modules.tenancy.models import Store, User
|
||||
from app.modules.tenancy.schemas.store import StoreCreate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -489,10 +488,7 @@ class StoreService:
|
||||
return True
|
||||
|
||||
# Check if user is owner via StoreUser relationship
|
||||
if user.is_owner_of(store.id):
|
||||
return True
|
||||
|
||||
return False
|
||||
return bool(user.is_owner_of(store.id))
|
||||
|
||||
def update_store(
|
||||
self,
|
||||
|
||||
@@ -24,6 +24,7 @@ from app.modules.tenancy.services.permission_discovery_service import (
|
||||
def get_preset_permissions(preset_name: str) -> set[str]:
|
||||
"""Get permissions for a preset role."""
|
||||
return permission_discovery_service.get_preset_permissions(preset_name)
|
||||
from app.modules.billing.exceptions import TierLimitExceededException
|
||||
from app.modules.tenancy.exceptions import (
|
||||
CannotRemoveOwnerException,
|
||||
InvalidInvitationTokenException,
|
||||
@@ -31,10 +32,8 @@ from app.modules.tenancy.exceptions import (
|
||||
TeamMemberAlreadyExistsException,
|
||||
UserNotFoundException,
|
||||
)
|
||||
from app.modules.billing.exceptions import TierLimitExceededException
|
||||
from app.modules.tenancy.models import Role, Store, StoreUser, StoreUserType, User
|
||||
from middleware.auth import AuthManager
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.models import Role, Store, StoreUser, StoreUserType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@ from typing import Any
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.tenancy.models import User
|
||||
from app.modules.tenancy.models import Role, StoreUser
|
||||
from app.modules.tenancy.models import Role, StoreUser, User
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ from sqlalchemy import func
|
||||
|
||||
from app.modules.contracts.features import (
|
||||
FeatureDeclaration,
|
||||
FeatureProviderProtocol,
|
||||
FeatureScope,
|
||||
FeatureType,
|
||||
FeatureUsage,
|
||||
@@ -113,9 +112,9 @@ class TenancyFeatureProvider:
|
||||
merchant_id: int,
|
||||
platform_id: int,
|
||||
) -> list[FeatureUsage]:
|
||||
from app.modules.tenancy.models.user import User
|
||||
from app.modules.tenancy.models.store import Store, StoreUser
|
||||
from app.modules.tenancy.models.store_platform import StorePlatform
|
||||
from app.modules.tenancy.models.user import User
|
||||
|
||||
# Count active users associated with stores owned by this merchant
|
||||
count = (
|
||||
|
||||
@@ -16,9 +16,8 @@ from sqlalchemy import func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.contracts.metrics import (
|
||||
MetricValue,
|
||||
MetricsContext,
|
||||
MetricsProviderProtocol,
|
||||
MetricValue,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -124,7 +123,14 @@ class TenancyMetricsProvider:
|
||||
- Total users
|
||||
- Active users
|
||||
"""
|
||||
from app.modules.tenancy.models import AdminPlatform, Merchant, StoreUser, User, Store, StorePlatform
|
||||
from app.modules.tenancy.models import (
|
||||
AdminPlatform,
|
||||
Merchant,
|
||||
Store,
|
||||
StorePlatform,
|
||||
StoreUser,
|
||||
User,
|
||||
)
|
||||
|
||||
try:
|
||||
# Store metrics - using StorePlatform junction table
|
||||
|
||||
@@ -15,7 +15,6 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.contracts.widgets import (
|
||||
DashboardWidget,
|
||||
DashboardWidgetProviderProtocol,
|
||||
ListWidget,
|
||||
WidgetContext,
|
||||
WidgetListItem,
|
||||
|
||||
Reference in New Issue
Block a user