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:
@@ -15,8 +15,6 @@ from app.modules.messaging.services.admin_notification_service import (
|
||||
Priority,
|
||||
Severity,
|
||||
)
|
||||
from app.modules.messaging.models import AdminNotification
|
||||
from app.modules.tenancy.models import PlatformAlert
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -260,7 +258,7 @@ class TestAdminNotificationServiceQuery:
|
||||
|
||||
def test_get_notifications_filter_read(self, db, notification_service, test_admin):
|
||||
"""Test filtering by read status."""
|
||||
n1 = notification_service.create_notification(
|
||||
notification_service.create_notification(
|
||||
db=db,
|
||||
notification_type=NotificationType.SYSTEM_ALERT,
|
||||
title="Unread",
|
||||
@@ -602,13 +600,13 @@ class TestPlatformAlertServiceQuery:
|
||||
def test_get_statistics(self, db, alert_service, test_admin):
|
||||
"""Test getting alert statistics."""
|
||||
# Create some alerts
|
||||
alert1 = alert_service.create_alert(
|
||||
alert_service.create_alert(
|
||||
db=db,
|
||||
alert_type=AlertType.SYSTEM,
|
||||
severity=Severity.WARNING,
|
||||
title="Active Warning",
|
||||
)
|
||||
alert2 = alert_service.create_alert(
|
||||
alert_service.create_alert(
|
||||
db=db,
|
||||
alert_type=AlertType.SECURITY,
|
||||
severity=Severity.CRITICAL,
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
import pytest
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.analytics.services.stats_service import stats_service
|
||||
from app.modules.tenancy.exceptions import (
|
||||
AdminOperationException,
|
||||
CannotModifySelfException,
|
||||
UserNotFoundException,
|
||||
UserStatusChangeException,
|
||||
StoreAlreadyExistsException,
|
||||
StoreNotFoundException,
|
||||
UserNotFoundException,
|
||||
UserStatusChangeException,
|
||||
)
|
||||
from app.modules.tenancy.services.admin_service import AdminService
|
||||
from app.modules.analytics.services.stats_service import stats_service
|
||||
from app.modules.tenancy.schemas.store import StoreCreate
|
||||
from app.modules.tenancy.services.admin_service import AdminService
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -193,7 +193,7 @@ class TestAdminService:
|
||||
assert isinstance(stats["total_users"], int)
|
||||
assert isinstance(stats["active_users"], int)
|
||||
assert isinstance(stats["inactive_users"], int)
|
||||
assert isinstance(stats["activation_rate"], (int, float))
|
||||
assert isinstance(stats["activation_rate"], int | float)
|
||||
|
||||
assert stats["total_users"] >= 2 # test_user + test_admin
|
||||
assert stats["active_users"] + stats["inactive_users"] == stats["total_users"]
|
||||
@@ -210,7 +210,7 @@ class TestAdminService:
|
||||
assert isinstance(stats["total_stores"], int)
|
||||
assert isinstance(stats["active_stores"], int)
|
||||
assert isinstance(stats["verified_stores"], int)
|
||||
assert isinstance(stats["verification_rate"], (int, float))
|
||||
assert isinstance(stats["verification_rate"], int | float)
|
||||
|
||||
assert stats["total_stores"] >= 1
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from app.modules.core.services.auth_service import AuthService
|
||||
from app.modules.tenancy.exceptions import (
|
||||
InvalidCredentialsException,
|
||||
UserNotActiveException,
|
||||
)
|
||||
from app.modules.core.services.auth_service import AuthService
|
||||
from models.schema.auth import UserLogin
|
||||
|
||||
|
||||
|
||||
@@ -5,14 +5,13 @@ import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.inventory.exceptions import (
|
||||
InsufficientInventoryException,
|
||||
InvalidQuantityException,
|
||||
InventoryNotFoundException,
|
||||
InventoryValidationException,
|
||||
)
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.inventory.services.inventory_service import InventoryService
|
||||
from app.modules.inventory.models import Inventory
|
||||
from app.modules.inventory.schemas import (
|
||||
InventoryAdjust,
|
||||
@@ -20,6 +19,7 @@ from app.modules.inventory.schemas import (
|
||||
InventoryReserve,
|
||||
InventoryUpdate,
|
||||
)
|
||||
from app.modules.inventory.services.inventory_service import InventoryService
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -363,9 +363,11 @@ class TestInventoryService:
|
||||
def test_get_product_inventory_no_inventory(self, db, test_product, test_store):
|
||||
"""Test getting inventory for product with no inventory entries."""
|
||||
# Create a new product without inventory
|
||||
from app.modules.marketplace.models import MarketplaceProduct
|
||||
from app.modules.marketplace.models import MarketplaceProductTranslation
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.marketplace.models import (
|
||||
MarketplaceProduct,
|
||||
MarketplaceProductTranslation,
|
||||
)
|
||||
|
||||
unique_id = str(uuid.uuid4())[:8]
|
||||
mp = MarketplaceProduct(
|
||||
|
||||
@@ -10,10 +10,12 @@ from app.modules.marketplace.exceptions import (
|
||||
ImportJobNotFoundException,
|
||||
ImportJobNotOwnedException,
|
||||
)
|
||||
from app.modules.tenancy.exceptions import UnauthorizedStoreAccessException
|
||||
from app.modules.marketplace.services.marketplace_import_job_service import MarketplaceImportJobService
|
||||
from app.modules.marketplace.models import MarketplaceImportJob
|
||||
from app.modules.marketplace.schemas import MarketplaceImportJobRequest
|
||||
from app.modules.marketplace.services.marketplace_import_job_service import (
|
||||
MarketplaceImportJobService,
|
||||
)
|
||||
from app.modules.tenancy.exceptions import UnauthorizedStoreAccessException
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -300,7 +302,7 @@ class TestMarketplaceImportJobService:
|
||||
self, db, test_store, test_user
|
||||
):
|
||||
"""Test converting model with all fields populated."""
|
||||
unique_id = str(uuid.uuid4())[:8]
|
||||
str(uuid.uuid4())[:8]
|
||||
from datetime import datetime
|
||||
|
||||
job = MarketplaceImportJob(
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.orders.exceptions import (
|
||||
ExceptionAlreadyResolvedException,
|
||||
InvalidProductForExceptionException,
|
||||
OrderItemExceptionNotFoundException,
|
||||
)
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.orders.services.order_item_exception_service import OrderItemExceptionService
|
||||
from app.modules.orders.models import OrderItem
|
||||
from app.modules.orders.models import OrderItemException
|
||||
from app.modules.orders.services.order_item_exception_service import (
|
||||
OrderItemExceptionService,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -12,22 +12,17 @@ Tests cover:
|
||||
"""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.customers.exceptions import CustomerNotFoundException
|
||||
from app.modules.orders.exceptions import OrderNotFoundException
|
||||
from app.modules.orders.models import Order
|
||||
from app.modules.orders.services.order_service import (
|
||||
PLACEHOLDER_GTIN,
|
||||
PLACEHOLDER_MARKETPLACE_ID,
|
||||
OrderService,
|
||||
order_service,
|
||||
)
|
||||
from app.modules.customers.models.customer import Customer
|
||||
from app.modules.orders.models import Order, OrderItem
|
||||
|
||||
|
||||
# Default address fields required by Order model
|
||||
DEFAULT_ADDRESS = {
|
||||
|
||||
@@ -5,11 +5,12 @@ import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
from app.modules.tenancy.exceptions import PlatformNotFoundException
|
||||
from app.modules.tenancy.services.platform_service import platform_service, PlatformStats
|
||||
from app.modules.tenancy.models import Platform, StorePlatform
|
||||
from app.modules.cms.models import ContentPage
|
||||
|
||||
from app.modules.tenancy.exceptions import PlatformNotFoundException
|
||||
from app.modules.tenancy.models import Platform, StorePlatform
|
||||
from app.modules.tenancy.services.platform_service import (
|
||||
platform_service,
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# FIXTURES
|
||||
|
||||
@@ -7,13 +7,16 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app.modules.tenancy.exceptions import AdminOperationException, StoreNotFoundException
|
||||
from app.modules.analytics.services.stats_service import StatsService
|
||||
from app.modules.inventory.models import Inventory
|
||||
from app.modules.marketplace.models import (
|
||||
MarketplaceProduct,
|
||||
MarketplaceProductTranslation,
|
||||
)
|
||||
from app.modules.tenancy.exceptions import (
|
||||
AdminOperationException,
|
||||
StoreNotFoundException,
|
||||
)
|
||||
|
||||
|
||||
def create_marketplace_product_with_translation(
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
# tests/unit/services/test_store_email_settings_service.py
|
||||
"""Unit tests for StoreEmailSettingsService."""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from datetime import datetime, timezone
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from app.exceptions import (
|
||||
AuthorizationException,
|
||||
ResourceNotFoundException,
|
||||
ValidationException,
|
||||
)
|
||||
from app.modules.cms.services.store_email_settings_service import store_email_settings_service
|
||||
from app.modules.messaging.models import StoreEmailSettings
|
||||
from app.modules.billing.models import TierCode
|
||||
|
||||
from app.modules.cms.services.store_email_settings_service import (
|
||||
store_email_settings_service,
|
||||
)
|
||||
from app.modules.messaging.models import StoreEmailSettings
|
||||
|
||||
# =============================================================================
|
||||
# FIXTURES
|
||||
@@ -58,7 +60,7 @@ def test_verified_email_settings(db, test_store):
|
||||
smtp_use_tls=True,
|
||||
is_configured=True,
|
||||
is_verified=True,
|
||||
last_verified_at=datetime.now(timezone.utc),
|
||||
last_verified_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(settings)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user