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

@@ -8,9 +8,9 @@ This module provides classes and functions for:
"""
import logging
from datetime import datetime, timezone
from datetime import UTC, datetime
from io import StringIO
from typing import Any, Dict
from typing import Any
import pandas as pd
import requests
@@ -145,7 +145,7 @@ class CSVProcessor:
logger.info(f"Normalized columns: {list(df.columns)}")
return df
def _clean_row_data(self, row_data: Dict[str, Any]) -> Dict[str, Any]:
def _clean_row_data(self, row_data: dict[str, Any]) -> dict[str, Any]:
"""Process a single row with data normalization."""
# Handle NaN values
processed_data = {k: (v if pd.notna(v) else None) for k, v in row_data.items()}
@@ -188,7 +188,7 @@ class CSVProcessor:
async def process_marketplace_csv_from_url(
self, url: str, marketplace: str, vendor_name: str, batch_size: int, db: Session
) -> Dict[str, Any]:
) -> dict[str, Any]:
"""
Process CSV from URL with marketplace and vendor information.
@@ -245,7 +245,7 @@ class CSVProcessor:
vendor_name: str,
db: Session,
batch_num: int,
) -> Dict[str, int]:
) -> dict[str, int]:
"""Process a batch of CSV rows with marketplace information."""
imported = 0
updated = 0
@@ -295,7 +295,7 @@ class CSVProcessor:
existing_product, key
):
setattr(existing_product, key, value)
existing_product.updated_at = datetime.now(timezone.utc)
existing_product.updated_at = datetime.now(UTC)
updated += 1
logger.debug(
f"Updated product {product_data['marketplace_product_id']} for "

View File

@@ -9,7 +9,6 @@ This module provides classes and functions for:
import logging
import re
from typing import Optional, Tuple
import pandas as pd
@@ -21,7 +20,7 @@ class GTINProcessor:
VALID_LENGTHS = [8, 12, 13, 14] # List of valid GTIN lengths
def normalize(self, gtin_value: any) -> Optional[str]:
def normalize(self, gtin_value: any) -> str | None:
"""
Normalize GTIN to proper format.
@@ -55,11 +54,11 @@ class GTINProcessor:
# Standard lengths - pad appropriately
if length == 8:
return gtin_clean.zfill(8) # EAN-8
elif length == 12:
if length == 12:
return gtin_clean.zfill(12) # UPC-A
elif length == 13:
if length == 13:
return gtin_clean.zfill(13) # EAN-13
elif length == 14:
if length == 14:
return gtin_clean.zfill(14) # GTIN-14
elif length > 14:
@@ -111,7 +110,7 @@ class PriceProcessor:
def parse_price_currency(
self, price_str: any
) -> Tuple[Optional[str], Optional[str]]:
) -> tuple[str | None, str | None]:
"""
Parse a price string to extract the numeric value and currency.

View File

@@ -40,7 +40,7 @@ def get_db_engine(database_url: str):
echo=False,
)
logger.info(f"Database engine created for: " f"{database_url.split('@')[0]}@...")
logger.info(f"Database engine created for: {database_url.split('@')[0]}@...")
return engine