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:
@@ -5,29 +5,29 @@ Orders module services.
|
||||
This module contains the canonical implementations of order-related services.
|
||||
"""
|
||||
|
||||
from app.modules.orders.services.order_service import (
|
||||
order_service,
|
||||
OrderService,
|
||||
)
|
||||
from app.modules.orders.services.order_inventory_service import (
|
||||
order_inventory_service,
|
||||
OrderInventoryService,
|
||||
)
|
||||
from app.modules.orders.services.order_item_exception_service import (
|
||||
order_item_exception_service,
|
||||
OrderItemExceptionService,
|
||||
)
|
||||
from app.modules.orders.services.invoice_service import (
|
||||
invoice_service,
|
||||
InvoiceService,
|
||||
from app.modules.orders.services.customer_order_service import (
|
||||
CustomerOrderService,
|
||||
customer_order_service,
|
||||
)
|
||||
from app.modules.orders.services.invoice_pdf_service import (
|
||||
invoice_pdf_service,
|
||||
InvoicePDFService,
|
||||
invoice_pdf_service,
|
||||
)
|
||||
from app.modules.orders.services.customer_order_service import (
|
||||
customer_order_service,
|
||||
CustomerOrderService,
|
||||
from app.modules.orders.services.invoice_service import (
|
||||
InvoiceService,
|
||||
invoice_service,
|
||||
)
|
||||
from app.modules.orders.services.order_inventory_service import (
|
||||
OrderInventoryService,
|
||||
order_inventory_service,
|
||||
)
|
||||
from app.modules.orders.services.order_item_exception_service import (
|
||||
OrderItemExceptionService,
|
||||
order_item_exception_service,
|
||||
)
|
||||
from app.modules.orders.services.order_service import (
|
||||
OrderService,
|
||||
order_service,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
|
||||
@@ -20,15 +20,15 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.orders.exceptions import (
|
||||
InvoiceSettingsNotFoundException,
|
||||
InvoiceNotFoundException,
|
||||
InvoiceSettingsNotFoundException,
|
||||
OrderNotFoundException,
|
||||
)
|
||||
from app.modules.orders.models.invoice import (
|
||||
Invoice,
|
||||
InvoiceStatus,
|
||||
VATRegime,
|
||||
StoreInvoiceSettings,
|
||||
VATRegime,
|
||||
)
|
||||
from app.modules.orders.models.order import Order
|
||||
from app.modules.orders.schemas.invoice import (
|
||||
@@ -126,9 +126,8 @@ class InvoiceService:
|
||||
if seller_oss_registered:
|
||||
vat_rate = self.get_vat_rate_for_country(buyer_country)
|
||||
return VATRegime.OSS, vat_rate, buyer_country
|
||||
else:
|
||||
vat_rate = self.get_vat_rate_for_country(seller_country)
|
||||
return VATRegime.ORIGIN, vat_rate, buyer_country
|
||||
vat_rate = self.get_vat_rate_for_country(seller_country)
|
||||
return VATRegime.ORIGIN, vat_rate, buyer_country
|
||||
|
||||
return VATRegime.EXEMPT, Decimal("0.00"), buyer_country
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ from sqlalchemy import func
|
||||
|
||||
from app.modules.contracts.features import (
|
||||
FeatureDeclaration,
|
||||
FeatureProviderProtocol,
|
||||
FeatureScope,
|
||||
FeatureType,
|
||||
FeatureUsage,
|
||||
|
||||
@@ -11,6 +11,7 @@ All operations are logged to the inventory_transactions table for audit trail.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
@@ -18,7 +19,6 @@ from app.modules.inventory.exceptions import (
|
||||
InsufficientInventoryException,
|
||||
InventoryNotFoundException,
|
||||
)
|
||||
from app.modules.orders.exceptions import OrderNotFoundException
|
||||
from app.modules.inventory.models.inventory import Inventory
|
||||
from app.modules.inventory.models.inventory_transaction import (
|
||||
InventoryTransaction,
|
||||
@@ -26,6 +26,7 @@ from app.modules.inventory.models.inventory_transaction import (
|
||||
)
|
||||
from app.modules.inventory.schemas.inventory import InventoryReserve
|
||||
from app.modules.inventory.services.inventory_service import inventory_service
|
||||
from app.modules.orders.exceptions import OrderNotFoundException
|
||||
from app.modules.orders.models.order import Order, OrderItem
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -136,10 +137,9 @@ class OrderInventoryService:
|
||||
"reason": "no_inventory",
|
||||
})
|
||||
continue
|
||||
else:
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
|
||||
try:
|
||||
reserve_data = InventoryReserve(
|
||||
@@ -237,10 +237,9 @@ class OrderInventoryService:
|
||||
"reason": "no_inventory",
|
||||
})
|
||||
continue
|
||||
else:
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
|
||||
try:
|
||||
reserve_data = InventoryReserve(
|
||||
@@ -367,10 +366,9 @@ class OrderInventoryService:
|
||||
"fulfilled_quantity": 0,
|
||||
"message": "No inventory found",
|
||||
}
|
||||
else:
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
|
||||
try:
|
||||
reserve_data = InventoryReserve(
|
||||
@@ -420,8 +418,7 @@ class OrderInventoryService:
|
||||
"fulfilled_quantity": 0,
|
||||
"message": str(e),
|
||||
}
|
||||
else:
|
||||
raise
|
||||
raise
|
||||
|
||||
def release_order_reservation(
|
||||
self,
|
||||
@@ -461,10 +458,9 @@ class OrderInventoryService:
|
||||
"reason": "no_inventory",
|
||||
})
|
||||
continue
|
||||
else:
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
raise InventoryNotFoundException(
|
||||
f"No inventory found for product {item.product_id}"
|
||||
)
|
||||
|
||||
try:
|
||||
reserve_data = InventoryReserve(
|
||||
|
||||
@@ -15,15 +15,15 @@ from datetime import UTC, datetime
|
||||
from sqlalchemy import and_, func, or_
|
||||
from sqlalchemy.orm import Session, joinedload
|
||||
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.orders.exceptions import (
|
||||
ExceptionAlreadyResolvedException,
|
||||
InvalidProductForExceptionException,
|
||||
OrderItemExceptionNotFoundException,
|
||||
)
|
||||
from app.modules.catalog.exceptions import ProductNotFoundException
|
||||
from app.modules.orders.exceptions import OrderItemExceptionNotFoundException
|
||||
from app.modules.orders.models.order import Order, OrderItem
|
||||
from app.modules.orders.models.order_item_exception import OrderItemException
|
||||
from app.modules.catalog.models import Product
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -25,31 +25,31 @@ from sqlalchemy import and_, func, or_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.exceptions import ValidationException
|
||||
from app.modules.billing.services.subscription_service import (
|
||||
TierLimitExceededException,
|
||||
subscription_service,
|
||||
)
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.customers.exceptions import CustomerNotFoundException
|
||||
from app.modules.inventory.exceptions import InsufficientInventoryException
|
||||
from app.modules.orders.exceptions import OrderNotFoundException
|
||||
from app.modules.customers.models.customer import Customer
|
||||
from app.modules.inventory.exceptions import InsufficientInventoryException
|
||||
from app.modules.marketplace.models import (
|
||||
MarketplaceProduct,
|
||||
MarketplaceProductTranslation,
|
||||
)
|
||||
from app.modules.orders.exceptions import OrderNotFoundException
|
||||
from app.modules.orders.models.order import Order, OrderItem
|
||||
from app.modules.orders.schemas.order import (
|
||||
AddressSnapshot,
|
||||
CustomerSnapshot,
|
||||
OrderCreate,
|
||||
OrderItemCreate,
|
||||
OrderUpdate,
|
||||
)
|
||||
from app.modules.billing.services.subscription_service import (
|
||||
subscription_service,
|
||||
TierLimitExceededException,
|
||||
)
|
||||
from app.modules.tenancy.models import Store
|
||||
from app.utils.money import Money, cents_to_euros, euros_to_cents
|
||||
from app.utils.vat import (
|
||||
VATResult,
|
||||
calculate_vat_amount,
|
||||
determine_vat_regime,
|
||||
)
|
||||
from app.modules.marketplace.models import MarketplaceProduct, MarketplaceProductTranslation
|
||||
from app.modules.catalog.models import Product
|
||||
from app.modules.tenancy.models import Store
|
||||
|
||||
# Placeholder product constants
|
||||
PLACEHOLDER_GTIN = "0000000000000"
|
||||
@@ -372,7 +372,7 @@ class OrderService:
|
||||
store_id=store_id,
|
||||
subtotal_cents=subtotal_cents,
|
||||
billing_country_iso=billing.country_iso,
|
||||
buyer_vat_number=getattr(billing, 'vat_number', None),
|
||||
buyer_vat_number=getattr(billing, "vat_number", None),
|
||||
)
|
||||
|
||||
# Calculate amounts in cents
|
||||
@@ -1291,7 +1291,9 @@ class OrderService:
|
||||
order_id: int,
|
||||
) -> dict[str, Any]:
|
||||
"""Get shipping label information for an order (admin only)."""
|
||||
from app.modules.core.services.admin_settings_service import admin_settings_service # noqa: MOD-004
|
||||
from app.modules.core.services.admin_settings_service import (
|
||||
admin_settings_service, # noqa: MOD-004
|
||||
)
|
||||
|
||||
order = db.query(Order).filter(Order.id == order_id).first()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user