refactor: modernize code quality tooling with Ruff

- Replace black, isort, and flake8 with Ruff (all-in-one linter and formatter)
- Add comprehensive pyproject.toml configuration
- Simplify Makefile code quality targets
- Configure exclusions for venv/.venv in pyproject.toml
- Auto-fix 1,359 linting issues across codebase

Benefits:
- Much faster builds (Ruff is written in Rust)
- Single tool replaces multiple tools
- More comprehensive rule set (UP, B, C4, SIM, PIE, RET, Q)
- All configuration centralized in pyproject.toml
- Better import sorting and formatting consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 19:37:38 +01:00
parent 21c13ca39b
commit 238c1ec9b8
169 changed files with 2183 additions and 1784 deletions

View File

@@ -1,7 +1,13 @@
# models/database/__init__.py
"""Database models package."""
from .admin import (AdminAuditLog, AdminNotification, AdminSession,
AdminSetting, PlatformAlert)
from .admin import (
AdminAuditLog,
AdminNotification,
AdminSession,
AdminSetting,
PlatformAlert,
)
from .base import Base
from .customer import Customer, CustomerAddress
from .inventory import Inventory

View File

@@ -10,8 +10,16 @@ This module provides models for:
- Platform alerts (system-wide issues)
"""
from sqlalchemy import (JSON, Boolean, Column, DateTime, ForeignKey, Integer,
String, Text)
from sqlalchemy import (
JSON,
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
String,
Text,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -1,17 +1,15 @@
from datetime import datetime, timezone
from datetime import UTC, datetime
from sqlalchemy import Column, DateTime
from app.core.database import Base
class TimestampMixin:
"""Mixin to add created_at and updated_at timestamps to models"""
created_at = Column(DateTime, default=datetime.now(timezone.utc), nullable=False)
created_at = Column(DateTime, default=datetime.now(UTC), nullable=False)
updated_at = Column(
DateTime,
default=datetime.now(timezone.utc),
onupdate=datetime.now(timezone.utc),
default=datetime.now(UTC),
onupdate=datetime.now(UTC),
nullable=False,
)

View File

@@ -1,9 +1,16 @@
# models/database/cart.py
"""Cart item database model."""
from datetime import datetime
from sqlalchemy import (Column, Float, ForeignKey, Index, Integer, String,
UniqueConstraint)
from sqlalchemy import (
Column,
Float,
ForeignKey,
Index,
Integer,
String,
UniqueConstraint,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -14,10 +14,19 @@ Features:
- Version history support
"""
from datetime import datetime, timezone
from datetime import UTC, datetime
from sqlalchemy import (Boolean, Column, DateTime, ForeignKey, Index, Integer,
String, Text, UniqueConstraint)
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Index,
Integer,
String,
Text,
UniqueConstraint,
)
from sqlalchemy.orm import relationship
from app.core.database import Base
@@ -77,13 +86,13 @@ class ContentPage(Base):
# Timestamps
created_at = Column(
DateTime(timezone=True),
default=lambda: datetime.now(timezone.utc),
default=lambda: datetime.now(UTC),
nullable=False,
)
updated_at = Column(
DateTime(timezone=True),
default=lambda: datetime.now(timezone.utc),
onupdate=lambda: datetime.now(timezone.utc),
default=lambda: datetime.now(UTC),
onupdate=lambda: datetime.now(UTC),
nullable=False,
)

View File

@@ -1,8 +1,14 @@
from datetime import datetime
from decimal import Decimal
from sqlalchemy import (JSON, Boolean, Column, DateTime, ForeignKey, Integer,
Numeric, String, Text)
from sqlalchemy import (
JSON,
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
Numeric,
String,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -1,8 +1,6 @@
# models/database/inventory.py
from datetime import datetime
from sqlalchemy import (Column, ForeignKey, Index, Integer, String,
UniqueConstraint)
from sqlalchemy import Column, ForeignKey, Index, Integer, String, UniqueConstraint
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -1,7 +1,5 @@
from datetime import datetime, timezone
from sqlalchemy import (Column, DateTime, ForeignKey, Index, Integer, String,
Text)
from sqlalchemy import Column, DateTime, ForeignKey, Index, Integer, String, Text
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -1,7 +1,10 @@
from datetime import datetime, timezone
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Index,
Integer, String, Text, UniqueConstraint)
from sqlalchemy import (
Column,
Index,
Integer,
String,
)
from sqlalchemy.orm import relationship
# Import Base from the central database module instead of creating a new one

View File

@@ -1,8 +1,15 @@
# models/database/order.py
from datetime import datetime
from sqlalchemy import (Boolean, Column, DateTime, Float, ForeignKey, Integer,
String, Text)
from sqlalchemy import (
Boolean,
Column,
DateTime,
Float,
ForeignKey,
Integer,
String,
Text,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -1,8 +1,15 @@
# models/database/product.py
from datetime import datetime
from sqlalchemy import (Boolean, Column, Float, ForeignKey, Index, Integer,
String, UniqueConstraint)
from sqlalchemy import (
Boolean,
Column,
Float,
ForeignKey,
Index,
Integer,
String,
UniqueConstraint,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -10,9 +10,10 @@ ROLE CLARIFICATION:
- Vendor-specific roles (manager, staff, etc.) are stored in VendorUser.role
- Customers are NOT in the User table - they use the Customer model
"""
import enum
from sqlalchemy import Boolean, Column, DateTime, Enum, Integer, String
from sqlalchemy import Boolean, Column, DateTime, Integer, String
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -5,13 +5,23 @@ Vendor model representing entities that sell products or services.
This module defines the Vendor model along with its relationships to
other models such as User (owner), Product, Customer, Order, and MarketplaceImportJob.
"""
import enum
from sqlalchemy import (JSON, Boolean, Column, DateTime, ForeignKey, Integer,
String, Text)
from sqlalchemy import (
JSON,
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
String,
Text,
)
from sqlalchemy.orm import relationship
from app.core.config import settings
# Import Base from the central database module instead of creating a new one
from app.core.database import Base
from models.database.base import TimestampMixin

View File

@@ -2,10 +2,18 @@
"""
Vendor Domain Model - Maps custom domains to vendors
"""
from datetime import datetime, timezone
from sqlalchemy import (Boolean, Column, DateTime, ForeignKey, Index, Integer,
String, UniqueConstraint)
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Index,
Integer,
String,
UniqueConstraint,
)
from sqlalchemy.orm import relationship
from app.core.database import Base

View File

@@ -3,6 +3,7 @@
Vendor Theme Configuration Model
Allows each vendor to customize their shop's appearance
"""
from sqlalchemy import JSON, Boolean, Column, ForeignKey, Integer, String, Text
from sqlalchemy.orm import relationship