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:
@@ -17,10 +17,9 @@ This allows:
|
||||
"""
|
||||
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from sqlalchemy import and_, or_
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from models.database.content_page import ContentPage
|
||||
@@ -35,9 +34,9 @@ class ContentPageService:
|
||||
def get_page_for_vendor(
|
||||
db: Session,
|
||||
slug: str,
|
||||
vendor_id: Optional[int] = None,
|
||||
vendor_id: int | None = None,
|
||||
include_unpublished: bool = False,
|
||||
) -> Optional[ContentPage]:
|
||||
) -> ContentPage | None:
|
||||
"""
|
||||
Get content page for a vendor with fallback to platform default.
|
||||
|
||||
@@ -90,11 +89,11 @@ class ContentPageService:
|
||||
@staticmethod
|
||||
def list_pages_for_vendor(
|
||||
db: Session,
|
||||
vendor_id: Optional[int] = None,
|
||||
vendor_id: int | None = None,
|
||||
include_unpublished: bool = False,
|
||||
footer_only: bool = False,
|
||||
header_only: bool = False,
|
||||
) -> List[ContentPage]:
|
||||
) -> list[ContentPage]:
|
||||
"""
|
||||
List all available pages for a vendor (includes vendor overrides + platform defaults).
|
||||
|
||||
@@ -156,16 +155,16 @@ class ContentPageService:
|
||||
slug: str,
|
||||
title: str,
|
||||
content: str,
|
||||
vendor_id: Optional[int] = None,
|
||||
vendor_id: int | None = None,
|
||||
content_format: str = "html",
|
||||
template: str = "default",
|
||||
meta_description: Optional[str] = None,
|
||||
meta_keywords: Optional[str] = None,
|
||||
meta_description: str | None = None,
|
||||
meta_keywords: str | None = None,
|
||||
is_published: bool = False,
|
||||
show_in_footer: bool = True,
|
||||
show_in_header: bool = False,
|
||||
display_order: int = 0,
|
||||
created_by: Optional[int] = None,
|
||||
created_by: int | None = None,
|
||||
) -> ContentPage:
|
||||
"""
|
||||
Create a new content page.
|
||||
@@ -199,7 +198,7 @@ class ContentPageService:
|
||||
meta_description=meta_description,
|
||||
meta_keywords=meta_keywords,
|
||||
is_published=is_published,
|
||||
published_at=datetime.now(timezone.utc) if is_published else None,
|
||||
published_at=datetime.now(UTC) if is_published else None,
|
||||
show_in_footer=show_in_footer,
|
||||
show_in_header=show_in_header,
|
||||
display_order=display_order,
|
||||
@@ -220,18 +219,18 @@ class ContentPageService:
|
||||
def update_page(
|
||||
db: Session,
|
||||
page_id: int,
|
||||
title: Optional[str] = None,
|
||||
content: Optional[str] = None,
|
||||
content_format: Optional[str] = None,
|
||||
template: Optional[str] = None,
|
||||
meta_description: Optional[str] = None,
|
||||
meta_keywords: Optional[str] = None,
|
||||
is_published: Optional[bool] = None,
|
||||
show_in_footer: Optional[bool] = None,
|
||||
show_in_header: Optional[bool] = None,
|
||||
display_order: Optional[int] = None,
|
||||
updated_by: Optional[int] = None,
|
||||
) -> Optional[ContentPage]:
|
||||
title: str | None = None,
|
||||
content: str | None = None,
|
||||
content_format: str | None = None,
|
||||
template: str | None = None,
|
||||
meta_description: str | None = None,
|
||||
meta_keywords: str | None = None,
|
||||
is_published: bool | None = None,
|
||||
show_in_footer: bool | None = None,
|
||||
show_in_header: bool | None = None,
|
||||
display_order: int | None = None,
|
||||
updated_by: int | None = None,
|
||||
) -> ContentPage | None:
|
||||
"""
|
||||
Update an existing content page.
|
||||
|
||||
@@ -275,7 +274,7 @@ class ContentPageService:
|
||||
if is_published is not None:
|
||||
page.is_published = is_published
|
||||
if is_published and not page.published_at:
|
||||
page.published_at = datetime.now(timezone.utc)
|
||||
page.published_at = datetime.now(UTC)
|
||||
if show_in_footer is not None:
|
||||
page.show_in_footer = show_in_footer
|
||||
if show_in_header is not None:
|
||||
@@ -316,14 +315,14 @@ class ContentPageService:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def get_page_by_id(db: Session, page_id: int) -> Optional[ContentPage]:
|
||||
def get_page_by_id(db: Session, page_id: int) -> ContentPage | None:
|
||||
"""Get content page by ID."""
|
||||
return db.query(ContentPage).filter(ContentPage.id == page_id).first()
|
||||
|
||||
@staticmethod
|
||||
def list_all_vendor_pages(
|
||||
db: Session, vendor_id: int, include_unpublished: bool = False
|
||||
) -> List[ContentPage]:
|
||||
) -> list[ContentPage]:
|
||||
"""
|
||||
List only vendor-specific pages (no platform defaults).
|
||||
|
||||
@@ -350,7 +349,7 @@ class ContentPageService:
|
||||
@staticmethod
|
||||
def list_all_platform_pages(
|
||||
db: Session, include_unpublished: bool = False
|
||||
) -> List[ContentPage]:
|
||||
) -> list[ContentPage]:
|
||||
"""
|
||||
List only platform default pages.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user