style: apply black and isort formatting across entire codebase

- Standardize quote style (single to double quotes)
- Reorder and group imports alphabetically
- Fix line breaks and indentation for consistency
- Apply PEP 8 formatting standards

Also updated Makefile to exclude both venv and .venv from code quality checks.

🤖 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:30:17 +01:00
parent 13f0094743
commit 21c13ca39b
236 changed files with 8450 additions and 6545 deletions

View File

@@ -14,6 +14,7 @@ This module focuses purely on configuration storage and validation.
"""
from typing import List, Optional
from pydantic_settings import BaseSettings
@@ -137,13 +138,9 @@ settings = Settings()
# ENVIRONMENT UTILITIES - Module-level functions
# =============================================================================
# Import environment detection utilities
from app.core.environment import (
get_environment,
is_development,
is_production,
is_staging,
should_use_secure_cookies
)
from app.core.environment import (get_environment, is_development,
is_production, is_staging,
should_use_secure_cookies)
def get_current_environment() -> str:
@@ -190,6 +187,7 @@ def is_staging_environment() -> bool:
# VALIDATION FUNCTIONS
# =============================================================================
def validate_production_settings() -> List[str]:
"""
Validate settings for production environment.
@@ -243,22 +241,19 @@ def print_environment_info():
# =============================================================================
__all__ = [
# Settings singleton
'settings',
"settings",
# Environment detection (re-exported from app.core.environment)
'get_environment',
'is_development',
'is_production',
'is_staging',
'should_use_secure_cookies',
"get_environment",
"is_development",
"is_production",
"is_staging",
"should_use_secure_cookies",
# Convenience functions
'get_current_environment',
'is_production_environment',
'is_development_environment',
'is_staging_environment',
"get_current_environment",
"is_production_environment",
"is_development_environment",
"is_staging_environment",
# Validation
'validate_production_settings',
'print_environment_info',
"validate_production_settings",
"print_environment_info",
]

View File

@@ -15,7 +15,7 @@ EnvironmentType = Literal["development", "staging", "production"]
def get_environment() -> EnvironmentType:
"""
Detect current environment automatically.
Detection logic:
1. Check ENV environment variable if set
2. Check ENVIRONMENT environment variable if set
@@ -23,7 +23,7 @@ def get_environment() -> EnvironmentType:
- localhost, 127.0.0.1 → development
- Contains 'staging' → staging
- Otherwise → production (safe default)
Returns:
str: 'development', 'staging', or 'production'
"""
@@ -35,7 +35,7 @@ def get_environment() -> EnvironmentType:
return "staging"
elif env in ["production", "prod"]:
return "production"
# Priority 2: ENVIRONMENT variable
env = os.getenv("ENVIRONMENT", "").lower()
if env in ["development", "dev", "local"]:
@@ -44,22 +44,25 @@ def get_environment() -> EnvironmentType:
return "staging"
elif env in ["production", "prod"]:
return "production"
# Priority 3: Auto-detect from common indicators
# Check if running in debug mode (common in development)
if os.getenv("DEBUG", "").lower() in ["true", "1", "yes"]:
return "development"
# Check common development indicators
hostname = os.getenv("HOSTNAME", "").lower()
if any(dev_indicator in hostname for dev_indicator in ["local", "dev", "laptop", "desktop"]):
if any(
dev_indicator in hostname
for dev_indicator in ["local", "dev", "laptop", "desktop"]
):
return "development"
# Check for staging indicators
if "staging" in hostname or "stage" in hostname:
return "staging"
# Default to development for safety (HTTPS not required in dev)
# Change this to "production" if you prefer secure-by-default
return "development"
@@ -83,7 +86,7 @@ def is_production() -> bool:
def should_use_secure_cookies() -> bool:
"""
Determine if cookies should have secure flag (HTTPS only).
Returns:
bool: True if production or staging, False if development
"""
@@ -97,7 +100,7 @@ _cached_environment: EnvironmentType | None = None
def get_cached_environment() -> EnvironmentType:
"""
Get environment with caching.
Environment is detected once and cached for performance.
Useful if you call this frequently.
"""

View File

@@ -15,11 +15,13 @@ from fastapi import FastAPI
from sqlalchemy import text
from middleware.auth import AuthManager
# Remove this import if not needed: from models.database.base import Base
from .database import SessionLocal, engine
from .logging import setup_logging
# Remove this import if not needed: from models.database.base import Base
logger = logging.getLogger(__name__)
auth_manager = AuthManager()
@@ -46,7 +48,9 @@ def check_database_ready():
try:
with engine.connect() as conn:
# Try to query a table that should exist
result = conn.execute(text("SELECT name FROM sqlite_master WHERE type='table' LIMIT 1"))
result = conn.execute(
text("SELECT name FROM sqlite_master WHERE type='table' LIMIT 1")
)
tables = result.fetchall()
return len(tables) > 0
except Exception:
@@ -93,6 +97,7 @@ def verify_startup_requirements():
logger.info("[OK] Startup verification passed")
return True
# You can call this in your main.py if desired:
# if not verify_startup_requirements():
# raise RuntimeError("Application startup requirements not met")

View File

@@ -17,6 +17,7 @@ class VendorPermissions(str, Enum):
Naming convention: RESOURCE_ACTION
"""
# Dashboard
DASHBOARD_VIEW = "dashboard.view"
@@ -166,17 +167,23 @@ class PermissionChecker:
return required_permission in permissions
@staticmethod
def has_any_permission(permissions: List[str], required_permissions: List[str]) -> bool:
def has_any_permission(
permissions: List[str], required_permissions: List[str]
) -> bool:
"""Check if a permission list contains ANY of the required permissions."""
return any(perm in permissions for perm in required_permissions)
@staticmethod
def has_all_permissions(permissions: List[str], required_permissions: List[str]) -> bool:
def has_all_permissions(
permissions: List[str], required_permissions: List[str]
) -> bool:
"""Check if a permission list contains ALL of the required permissions."""
return all(perm in permissions for perm in required_permissions)
@staticmethod
def get_missing_permissions(permissions: List[str], required_permissions: List[str]) -> List[str]:
def get_missing_permissions(
permissions: List[str], required_permissions: List[str]
) -> List[str]:
"""Get list of missing permissions."""
return [perm for perm in required_permissions if perm not in permissions]

View File

@@ -16,19 +16,11 @@ THEME_PRESETS = {
"accent": "#ec4899", # Pink
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#e5e7eb" # Gray-200
"border": "#e5e7eb", # Gray-200
},
"fonts": {
"heading": "Inter, sans-serif",
"body": "Inter, sans-serif"
},
"layout": {
"style": "grid",
"header": "fixed",
"product_card": "modern"
}
"fonts": {"heading": "Inter, sans-serif", "body": "Inter, sans-serif"},
"layout": {"style": "grid", "header": "fixed", "product_card": "modern"},
},
"modern": {
"colors": {
"primary": "#6366f1", # Indigo - Modern tech look
@@ -36,19 +28,11 @@ THEME_PRESETS = {
"accent": "#ec4899", # Pink
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#e5e7eb" # Gray-200
"border": "#e5e7eb", # Gray-200
},
"fonts": {
"heading": "Inter, sans-serif",
"body": "Inter, sans-serif"
},
"layout": {
"style": "grid",
"header": "fixed",
"product_card": "modern"
}
"fonts": {"heading": "Inter, sans-serif", "body": "Inter, sans-serif"},
"layout": {"style": "grid", "header": "fixed", "product_card": "modern"},
},
"classic": {
"colors": {
"primary": "#1e40af", # Dark blue - Traditional
@@ -56,19 +40,11 @@ THEME_PRESETS = {
"accent": "#dc2626", # Red
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#d1d5db" # Gray-300
"border": "#d1d5db", # Gray-300
},
"fonts": {
"heading": "Georgia, serif",
"body": "Arial, sans-serif"
},
"layout": {
"style": "list",
"header": "static",
"product_card": "classic"
}
"fonts": {"heading": "Georgia, serif", "body": "Arial, sans-serif"},
"layout": {"style": "list", "header": "static", "product_card": "classic"},
},
"minimal": {
"colors": {
"primary": "#000000", # Black - Ultra minimal
@@ -76,19 +52,11 @@ THEME_PRESETS = {
"accent": "#666666", # Medium gray
"background": "#ffffff", # White
"text": "#000000", # Black
"border": "#e5e7eb" # Light gray
"border": "#e5e7eb", # Light gray
},
"fonts": {
"heading": "Helvetica, sans-serif",
"body": "Helvetica, sans-serif"
},
"layout": {
"style": "grid",
"header": "transparent",
"product_card": "minimal"
}
"fonts": {"heading": "Helvetica, sans-serif", "body": "Helvetica, sans-serif"},
"layout": {"style": "grid", "header": "transparent", "product_card": "minimal"},
},
"vibrant": {
"colors": {
"primary": "#f59e0b", # Orange - Bold & energetic
@@ -96,19 +64,11 @@ THEME_PRESETS = {
"accent": "#8b5cf6", # Purple
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#fbbf24" # Yellow
"border": "#fbbf24", # Yellow
},
"fonts": {
"heading": "Poppins, sans-serif",
"body": "Open Sans, sans-serif"
},
"layout": {
"style": "masonry",
"header": "fixed",
"product_card": "modern"
}
"fonts": {"heading": "Poppins, sans-serif", "body": "Open Sans, sans-serif"},
"layout": {"style": "masonry", "header": "fixed", "product_card": "modern"},
},
"elegant": {
"colors": {
"primary": "#6b7280", # Gray - Sophisticated
@@ -116,19 +76,11 @@ THEME_PRESETS = {
"accent": "#d97706", # Amber
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#e5e7eb" # Gray-200
"border": "#e5e7eb", # Gray-200
},
"fonts": {
"heading": "Playfair Display, serif",
"body": "Lato, sans-serif"
},
"layout": {
"style": "grid",
"header": "fixed",
"product_card": "classic"
}
"fonts": {"heading": "Playfair Display, serif", "body": "Lato, sans-serif"},
"layout": {"style": "grid", "header": "fixed", "product_card": "classic"},
},
"nature": {
"colors": {
"primary": "#059669", # Green - Natural & eco
@@ -136,18 +88,11 @@ THEME_PRESETS = {
"accent": "#f59e0b", # Amber
"background": "#ffffff", # White
"text": "#1f2937", # Gray-800
"border": "#d1fae5" # Light green
"border": "#d1fae5", # Light green
},
"fonts": {
"heading": "Montserrat, sans-serif",
"body": "Open Sans, sans-serif"
},
"layout": {
"style": "grid",
"header": "fixed",
"product_card": "modern"
}
}
"fonts": {"heading": "Montserrat, sans-serif", "body": "Open Sans, sans-serif"},
"layout": {"style": "grid", "header": "fixed", "product_card": "modern"},
},
}
@@ -243,7 +188,7 @@ def get_preset_preview(preset_name: str) -> dict:
"minimal": "Ultra-clean black and white aesthetic",
"vibrant": "Bold and energetic with bright accent colors",
"elegant": "Sophisticated gray tones with refined typography",
"nature": "Fresh and eco-friendly green color palette"
"nature": "Fresh and eco-friendly green color palette",
}
return {
@@ -259,10 +204,7 @@ def get_preset_preview(preset_name: str) -> dict:
def create_custom_preset(
colors: dict,
fonts: dict,
layout: dict,
name: str = "custom"
colors: dict, fonts: dict, layout: dict, name: str = "custom"
) -> dict:
"""
Create a custom preset from provided settings.
@@ -304,8 +246,4 @@ def create_custom_preset(
if "product_card" not in layout:
layout["product_card"] = "modern"
return {
"colors": colors,
"fonts": fonts,
"layout": layout
}
return {"colors": colors, "fonts": fonts, "layout": layout}