chore(quality): apply ruff autofixes and formatting (223 fixes, regression-free: 118/118 tests pass)

This commit is contained in:
Agent Zero
2026-06-10 21:24:24 +00:00
parent c53af91d74
commit aec40d03ac
56 changed files with 459 additions and 528 deletions
+7 -14
View File
@@ -5,7 +5,6 @@ from __future__ import annotations
from collections import defaultdict
from datetime import UTC, datetime
from decimal import Decimal
from typing import Optional
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession
@@ -75,9 +74,7 @@ async def create_deal(
return deal
async def get_deal(
db: AsyncSession, deal_id: int, *, org_id: int
) -> Optional[Deal]:
async def get_deal(db: AsyncSession, deal_id: int, *, org_id: int) -> Deal | None:
"""Fetch a single deal by id."""
q = OrgScopedQuery(Deal, db, org_id=org_id)
return await q.get(deal_id)
@@ -89,9 +86,9 @@ async def list_deals(
org_id: int,
skip: int = 0,
limit: int = 20,
stage: Optional[str] = None,
owner_id: Optional[int] = None,
account_id: Optional[int] = None,
stage: str | None = None,
owner_id: int | None = None,
account_id: int | None = None,
) -> list[Deal]:
"""List deals with optional filters."""
scoped = OrgScopedQuery(Deal, db, org_id=org_id)
@@ -105,9 +102,7 @@ async def list_deals(
)
async def update_deal(
db: AsyncSession, deal: Deal, payload: DealUpdate
) -> Deal:
async def update_deal(db: AsyncSession, deal: Deal, payload: DealUpdate) -> Deal:
"""Apply partial updates to a deal. Does NOT change stage (use update_stage)."""
data = payload.model_dump(exclude_unset=True)
# Disallow direct stage changes via update endpoint
@@ -126,7 +121,7 @@ async def update_stage(
new_stage: DealStage,
*,
changed_by: int,
reason: Optional[str] = None,
reason: str | None = None,
) -> Deal:
"""Change a deal's stage and append a DealStageHistory record."""
from_stage_str = _stage_value(deal.stage)
@@ -151,9 +146,7 @@ async def update_stage(
return deal
async def get_pipeline(
db: AsyncSession, *, org_id: int
) -> list[dict[str, object]]:
async def get_pipeline(db: AsyncSession, *, org_id: int) -> list[dict[str, object]]:
"""Return deals grouped by stage for the pipeline view."""
scoped = OrgScopedQuery(Deal, db, org_id=org_id)
all_deals = await scoped.list(skip=0, limit=10_000, order_by=Deal.id)