Problem: - Ruff removed 'from app.core.database import Base' from models/database/base.py - Import appeared "unused" (F401) but was actually a critical re-export - Caused ImportError: cannot import name 'Base' at runtime - Re-export pattern: import in one file to export from package Solution: 1. Added F401 ignore for models/database/base.py in pyproject.toml 2. Created scripts/verify_critical_imports.py verification script 3. Integrated verification into make check and CI pipeline 4. Updated documentation with explanation New Verification Script: - Checks all critical re-export imports exist - Detects import variations (parentheses, 'as' clauses) - Handles SQLAlchemy declarative_base alternatives - Runs as part of make check automatically Protected Files: - models/database/base.py - Re-exports Base for all models - models/__init__.py - Exports Base for Alembic - models/database/__init__.py - Exports Base from package - All __init__.py files (already protected) Makefile Changes: - make verify-imports - Run import verification - make check - Now includes verify-imports - make ci - Includes verify-imports in pipeline Documentation Updated: - Code quality guide explains re-export protection - Pre-commit workflow includes verification - Examples of why re-exports matter This prevents future issues where linters remove seemingly "unused" imports that are actually critical for application structure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
from sqlalchemy import Column, DateTime, ForeignKey, Index, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.core.database import Base
|
|
from models.database.base import TimestampMixin
|
|
|
|
|
|
class MarketplaceImportJob(Base, TimestampMixin):
|
|
__tablename__ = "marketplace_import_jobs"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
vendor_id = Column(Integer, ForeignKey("vendors.id"), nullable=False, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
|
|
# Import configuration
|
|
marketplace = Column(String, nullable=False, index=True, default="Letzshop")
|
|
source_url = Column(String, nullable=False)
|
|
|
|
# Status tracking
|
|
status = Column(
|
|
String, nullable=False, default="pending"
|
|
) # pending, processing, completed, failed, completed_with_errors
|
|
|
|
# Results
|
|
imported_count = Column(Integer, default=0)
|
|
updated_count = Column(Integer, default=0)
|
|
error_count = Column(Integer, default=0)
|
|
total_processed = Column(Integer, default=0)
|
|
|
|
# Error handling
|
|
error_message = Column(Text)
|
|
|
|
# Timestamps
|
|
started_at = Column(DateTime(timezone=True))
|
|
completed_at = Column(DateTime(timezone=True))
|
|
|
|
# Relationships
|
|
vendor = relationship("Vendor", back_populates="marketplace_import_jobs")
|
|
user = relationship("User", foreign_keys=[user_id])
|
|
|
|
# Indexes for performance
|
|
__table_args__ = (
|
|
Index("idx_import_vendor_status", "vendor_id", "status"),
|
|
Index("idx_import_vendor_created", "vendor_id", "created_at"),
|
|
Index("idx_import_user_marketplace", "user_id", "marketplace"),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return (
|
|
f"<MarketplaceImportJob(id={self.id}, vendor_id={self.vendor_id}, "
|
|
f"marketplace='{self.marketplace}', status='{self.status}', "
|
|
f"imported={self.imported_count})>"
|
|
)
|