fix(fc2a): satisfy ruff 0.15.13 lint — UP017, UP042, I001

Ruff lint surfaced 23 violations across three rules; all addressed:

UP017 (Use datetime.UTC alias):
  Replaced 13 sites of datetime.now(timezone.utc) with datetime.now(UTC),
  also adjusted from-imports accordingly. UTC is a Python 3.11+ alias for
  timezone.utc that ruff's pyupgrade rules prefer.

UP042 (StrEnum):
  Replaced `class TagKind(str, Enum)` and `class SkipReason(str, Enum)`
  with `class Foo(StrEnum)`. StrEnum was added in Python 3.11 stdlib and
  is the modern idiom. Behavior is equivalent for our usage (the .value
  attribute, str(member) semantics).

I001 (Import sorting):
  Added `known-first-party = ["backend"]` to ruff.toml's [lint.isort] so
  ruff groups `backend.*` imports correctly. Without it, ruff treated
  them as third-party and demanded a different grouping. The existing
  import order is stdlib → third-party → first-party → local relative,
  which ruff now accepts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 14:11:35 -04:00
parent 117873423b
commit b4e0d680f1
10 changed files with 31 additions and 26 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
"""Periodic maintenance: recover stuck import tasks, garbage-collect old finished tasks."""
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from sqlalchemy import create_engine, delete, select, update
from sqlalchemy.orm import sessionmaker
@@ -29,7 +29,7 @@ def recover_interrupted_tasks() -> int:
forever) without resetting slow-but-still-running jobs.
"""
SessionLocal = _sync_session_factory()
cutoff = datetime.now(timezone.utc) - timedelta(minutes=STUCK_THRESHOLD_MINUTES)
cutoff = datetime.now(UTC) - timedelta(minutes=STUCK_THRESHOLD_MINUTES)
with SessionLocal() as session:
stuck_ids = session.execute(
select(ImportTask.id)
@@ -63,7 +63,7 @@ def cleanup_old_tasks() -> int:
rather than an archive. Matches IR's default.
"""
SessionLocal = _sync_session_factory()
cutoff = datetime.now(timezone.utc) - timedelta(days=OLD_TASK_DAYS)
cutoff = datetime.now(UTC) - timedelta(days=OLD_TASK_DAYS)
with SessionLocal() as session:
result = session.execute(
delete(ImportTask)