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 -18
View File
@@ -3,7 +3,6 @@
from __future__ import annotations
from datetime import UTC, datetime
from typing import Optional
from sqlalchemy.ext.asyncio import AsyncSession
@@ -37,19 +36,13 @@ async def _validate_parent(
"""Verify the (parent_type, parent_id) tuple points to an existing entity in org."""
if parent_type == NoteParentType.account:
if await OrgScopedQuery(Account, db, org_id=org_id).get(parent_id) is None:
raise InvalidParent(
f"Account {parent_id} not found in this org (R-2 validation)"
)
raise InvalidParent(f"Account {parent_id} not found in this org (R-2 validation)")
elif parent_type == NoteParentType.contact:
if await OrgScopedQuery(Contact, db, org_id=org_id).get(parent_id) is None:
raise InvalidParent(
f"Contact {parent_id} not found in this org (R-2 validation)"
)
raise InvalidParent(f"Contact {parent_id} not found in this org (R-2 validation)")
elif parent_type == NoteParentType.deal:
if await OrgScopedQuery(Deal, db, org_id=org_id).get(parent_id) is None:
raise InvalidParent(
f"Deal {parent_id} not found in this org (R-2 validation)"
)
raise InvalidParent(f"Deal {parent_id} not found in this org (R-2 validation)")
async def create_note(
@@ -84,9 +77,7 @@ async def create_note(
return note
async def get_note(
db: AsyncSession, note_id: int, *, org_id: int
) -> Optional[Note]:
async def get_note(db: AsyncSession, note_id: int, *, org_id: int) -> Note | None:
"""Fetch a single note by id."""
q = OrgScopedQuery(Note, db, org_id=org_id)
return await q.get(note_id)
@@ -98,8 +89,8 @@ async def list_notes(
org_id: int,
skip: int = 0,
limit: int = 20,
parent_type: Optional[str] = None,
parent_id: Optional[int] = None,
parent_type: str | None = None,
parent_id: int | None = None,
) -> list[Note]:
"""List notes with optional parent filters."""
scoped = OrgScopedQuery(Note, db, org_id=org_id)
@@ -112,9 +103,7 @@ async def list_notes(
)
async def update_note(
db: AsyncSession, note: Note, payload: NoteUpdate
) -> Note:
async def update_note(db: AsyncSession, note: Note, payload: NoteUpdate) -> Note:
"""Apply partial updates to a note. Does NOT change parent (notes are pinned)."""
data = payload.model_dump(exclude_unset=True)
data.pop("parent_type", None)