fix: protect critical re-export imports from linter removal
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>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# models/database/cart.py
|
||||
"""Cart item database model."""
|
||||
|
||||
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
Float,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
from sqlalchemy import (
|
||||
JSON,
|
||||
Boolean,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
from sqlalchemy import Column, DateTime, ForeignKey, Index, Integer, String, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
Index,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Vendor Domain Model - Maps custom domains to vendors
|
||||
"""
|
||||
|
||||
|
||||
from sqlalchemy import (
|
||||
Boolean,
|
||||
Column,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Pydantic schemas for shopping cart operations.
|
||||
"""
|
||||
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
# ============================================================================
|
||||
|
||||
@@ -11,9 +11,7 @@ class ProductCreate(BaseModel):
|
||||
marketplace_product_id: int = Field(
|
||||
..., description="MarketplaceProduct ID to add to vendor catalog"
|
||||
)
|
||||
product_id: str | None = Field(
|
||||
None, description="Vendor's internal SKU/product ID"
|
||||
)
|
||||
product_id: str | None = Field(None, description="Vendor's internal SKU/product ID")
|
||||
price: float | None = Field(None, ge=0)
|
||||
sale_price: float | None = Field(None, ge=0)
|
||||
currency: str | None = None
|
||||
|
||||
@@ -31,7 +31,6 @@ class RoleCreate(RoleBase):
|
||||
"""Schema for creating a role."""
|
||||
|
||||
|
||||
|
||||
class RoleUpdate(BaseModel):
|
||||
"""Schema for updating a role."""
|
||||
|
||||
|
||||
@@ -100,9 +100,7 @@ class VendorUpdate(BaseModel):
|
||||
subdomain: str | None = Field(None, min_length=2, max_length=100)
|
||||
|
||||
# Business Contact Information (Vendor Fields)
|
||||
contact_email: str | None = Field(
|
||||
None, description="Public business contact email"
|
||||
)
|
||||
contact_email: str | None = Field(None, description="Public business contact email")
|
||||
contact_phone: str | None = None
|
||||
website: str | None = None
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
Pydantic schemas for vendor theme operations.
|
||||
"""
|
||||
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
@@ -54,14 +53,10 @@ class VendorThemeUpdate(BaseModel):
|
||||
theme_name: str | None = Field(None, description="Theme preset name")
|
||||
colors: dict[str, str] | None = Field(None, description="Color scheme")
|
||||
fonts: dict[str, str] | None = Field(None, description="Font settings")
|
||||
branding: dict[str, str | None] | None = Field(
|
||||
None, description="Branding assets"
|
||||
)
|
||||
branding: dict[str, str | None] | None = Field(None, description="Branding assets")
|
||||
layout: dict[str, str] | None = Field(None, description="Layout settings")
|
||||
custom_css: str | None = Field(None, description="Custom CSS rules")
|
||||
social_links: dict[str, str] | None = Field(
|
||||
None, description="Social media links"
|
||||
)
|
||||
social_links: dict[str, str] | None = Field(None, description="Social media links")
|
||||
|
||||
|
||||
class VendorThemeResponse(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user