fix(fc5): ruff (E712, ASYNC230/240, I001) + Credential.credential_type + FileStorage in api_migrate test

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 13:20:42 -04:00
parent 26fd3f9f2c
commit e5885f85c5
4 changed files with 36 additions and 30 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ async def migrate_async(
encrypted = fc_crypto.encrypt(cred["plaintext"])
db.add(Credential(
platform=cred["platform"],
kind=cred.get("credential_type") or "cookies",
credential_type=cred.get("credential_type") or "cookies",
encrypted_blob=encrypted,
expires_at=cred.get("expires_at"),
))
+6 -3
View File
@@ -18,7 +18,7 @@ async def verify_async(db: AsyncSession, *, expected: dict | None = None) -> dic
checks = {
"artist_subscriptions": (
select(func.count(Artist.id)).where(Artist.is_subscription == True)
select(func.count(Artist.id)).where(Artist.is_subscription.is_(True))
),
"source_count": select(func.count(Source.id)),
"credential_count": select(func.count(Credential.id)),
@@ -51,12 +51,15 @@ async def verify_sha256_sample(
samples: list[dict] = []
for img_id, path, expected_sha in rows:
p = Path(path)
if not p.exists():
# Sync stdlib filesystem ops are intentional: this verify pass runs
# inside a Celery task under asyncio.run; no other awaitables compete
# for the loop. Same pattern as download_service.py.
if not p.exists(): # noqa: ASYNC240
missing += 1
samples.append({"id": img_id, "path": path, "result": "missing"})
continue
h = hashlib.sha256()
with p.open("rb") as f:
with p.open("rb") as f: # noqa: ASYNC230
for chunk in iter(lambda: f.read(65536), b""):
h.update(chunk)
if h.hexdigest() == expected_sha:
+4 -9
View File
@@ -20,15 +20,10 @@ from ..celery_app import celery
from ..config import get_config
from ..models import MigrationRun
from ..services.credential_crypto import CredentialCrypto
from ..services.migrators import (
backup as backup_mod,
gs_ingest,
ir_ingest,
ml_queue,
rollback as rollback_mod,
tag_apply,
verify,
)
from ..services.migrators import backup as backup_mod
from ..services.migrators import gs_ingest, ir_ingest, ml_queue
from ..services.migrators import rollback as rollback_mod
from ..services.migrators import tag_apply, verify
log = logging.getLogger(__name__)