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:
@@ -26,10 +26,9 @@ This script is idempotent when run normally.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from typing import Dict, List
|
||||
|
||||
# Add project root to path
|
||||
project_root = Path(__file__).parent.parent
|
||||
@@ -260,7 +259,7 @@ def reset_all_data(db: Session):
|
||||
# =============================================================================
|
||||
|
||||
|
||||
def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
def create_demo_vendors(db: Session, auth_manager: AuthManager) -> list[Vendor]:
|
||||
"""Create demo vendors with users."""
|
||||
|
||||
vendors = []
|
||||
@@ -291,8 +290,8 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
last_name=user_data["last_name"],
|
||||
is_active=True,
|
||||
is_email_verified=True,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(vendor_user)
|
||||
db.flush()
|
||||
@@ -305,8 +304,8 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
description=vendor_data["description"],
|
||||
is_active=True,
|
||||
is_verified=True,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(vendor)
|
||||
db.flush()
|
||||
@@ -317,7 +316,7 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
user_id=vendor_user.id,
|
||||
user_type="owner",
|
||||
is_active=True,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(vendor_user_link)
|
||||
|
||||
@@ -334,8 +333,8 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
background_color=theme_colors["background"],
|
||||
text_color=theme_colors["text"],
|
||||
is_active=True,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(theme)
|
||||
|
||||
@@ -347,8 +346,8 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
is_verified=True, # Auto-verified for demo
|
||||
is_active=True,
|
||||
verification_token=None,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(domain)
|
||||
|
||||
@@ -361,7 +360,7 @@ def create_demo_vendors(db: Session, auth_manager: AuthManager) -> List[Vendor]:
|
||||
|
||||
def create_demo_customers(
|
||||
db: Session, vendor: Vendor, auth_manager: AuthManager, count: int
|
||||
) -> List[Customer]:
|
||||
) -> list[Customer]:
|
||||
"""Create demo customers for a vendor."""
|
||||
|
||||
customers = []
|
||||
@@ -388,12 +387,12 @@ def create_demo_customers(
|
||||
email=email,
|
||||
hashed_password=auth_manager.hash_password(demo_password),
|
||||
first_name=f"Customer{i}",
|
||||
last_name=f"Test",
|
||||
last_name="Test",
|
||||
phone=f"+352123456{i:03d}",
|
||||
customer_number=customer_number,
|
||||
is_active=True,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(customer)
|
||||
customers.append(customer)
|
||||
@@ -409,7 +408,7 @@ def create_demo_customers(
|
||||
return customers
|
||||
|
||||
|
||||
def create_demo_products(db: Session, vendor: Vendor, count: int) -> List[Product]:
|
||||
def create_demo_products(db: Session, vendor: Vendor, count: int) -> list[Product]:
|
||||
"""Create demo products for a vendor."""
|
||||
|
||||
products = []
|
||||
@@ -455,8 +454,8 @@ def create_demo_products(db: Session, vendor: Vendor, count: int) -> List[Produc
|
||||
marketplace="Wizamart",
|
||||
vendor_name=vendor.name,
|
||||
currency="EUR",
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(marketplace_product)
|
||||
db.flush() # Flush to get the marketplace_product.id
|
||||
@@ -474,8 +473,8 @@ def create_demo_products(db: Session, vendor: Vendor, count: int) -> List[Produc
|
||||
is_featured=(i % 5 == 0), # Every 5th product is featured
|
||||
display_order=i,
|
||||
min_quantity=1,
|
||||
created_at=datetime.now(timezone.utc),
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(product)
|
||||
products.append(product)
|
||||
@@ -548,7 +547,7 @@ def print_summary(db: Session):
|
||||
customer_count = db.query(Customer).count()
|
||||
product_count = db.query(Product).count()
|
||||
|
||||
print(f"\n📊 Database Status:")
|
||||
print("\n📊 Database Status:")
|
||||
print(f" Vendors: {vendor_count}")
|
||||
print(f" Users: {user_count}")
|
||||
print(f" Customers: {customer_count}")
|
||||
@@ -556,7 +555,7 @@ def print_summary(db: Session):
|
||||
|
||||
# Show vendor details
|
||||
vendors = db.query(Vendor).all()
|
||||
print(f"\n🏪 Demo Vendors:")
|
||||
print("\n🏪 Demo Vendors:")
|
||||
for vendor in vendors:
|
||||
print(f"\n {vendor.name} ({vendor.vendor_code})")
|
||||
print(f" Subdomain: {vendor.subdomain}.{settings.platform_domain}")
|
||||
@@ -580,7 +579,7 @@ def print_summary(db: Session):
|
||||
|
||||
print(f" Status: {'✓ Active' if vendor.is_active else '✗ Inactive'}")
|
||||
|
||||
print(f"\n🔐 Demo Vendor Credentials:")
|
||||
print("\n🔐 Demo Vendor Credentials:")
|
||||
print("─" * 70)
|
||||
for i, vendor_data in enumerate(DEMO_VENDOR_USERS[:vendor_count], 1):
|
||||
vendor = vendors[i - 1] if i <= len(vendors) else None
|
||||
@@ -597,15 +596,15 @@ def print_summary(db: Session):
|
||||
)
|
||||
print()
|
||||
|
||||
print(f"\n🛒 Demo Customer Credentials:")
|
||||
print("\n🛒 Demo Customer Credentials:")
|
||||
print("─" * 70)
|
||||
print(f" All customers:")
|
||||
print(f" Email: customer1@{{subdomain}}.example.com")
|
||||
print(f" Password: customer123")
|
||||
print(f" (Replace {{subdomain}} with vendor subdomain, e.g., wizamart)")
|
||||
print(" All customers:")
|
||||
print(" Email: customer1@{subdomain}.example.com")
|
||||
print(" Password: customer123")
|
||||
print(" (Replace {subdomain} with vendor subdomain, e.g., wizamart)")
|
||||
print()
|
||||
|
||||
print(f"\n🏪 Shop Access (Development):")
|
||||
print("\n🏪 Shop Access (Development):")
|
||||
print("─" * 70)
|
||||
for vendor in vendors:
|
||||
print(f" {vendor.name}:")
|
||||
@@ -622,8 +621,8 @@ def print_summary(db: Session):
|
||||
print(" 2. Login as vendor:")
|
||||
print(" • Path-based: http://localhost:8000/vendor/WIZAMART/login")
|
||||
print(" • Subdomain: http://wizamart.localhost:8000/vendor/login")
|
||||
print(f" 3. Visit vendor shop: http://localhost:8000/vendors/WIZAMART/shop/")
|
||||
print(f" 4. Admin panel: http://localhost:8000/admin/login")
|
||||
print(" 3. Visit vendor shop: http://localhost:8000/vendors/WIZAMART/shop/")
|
||||
print(" 4. Admin panel: http://localhost:8000/admin/login")
|
||||
print(f" Username: {settings.admin_username}")
|
||||
print(f" Password: {settings.admin_password}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user