From 29598c3f9a11fabc74226cf635a02a4d2d8bc00a Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 20 May 2026 20:50:38 -0400 Subject: [PATCH] =?UTF-8?q?fix(fc3c):=20ruff=20=E2=80=94=20split=20SyncSes?= =?UTF-8?q?sion=20import,=20StrEnum,=20ASYNC240=20noqa,=20blank-line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/app/services/download_service.py | 12 ++++++++---- backend/app/services/file_validator.py | 1 - backend/app/services/gallery_dl.py | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/app/services/download_service.py b/backend/app/services/download_service.py index 2a8778a..b62dcd0 100644 --- a/backend/app/services/download_service.py +++ b/backend/app/services/download_service.py @@ -20,7 +20,8 @@ from typing import Any from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.orm import Session as SyncSession, joinedload +from sqlalchemy.orm import Session as SyncSession +from sqlalchemy.orm import joinedload from ..models import Artist, DownloadEvent, Source from .credential_service import CredentialService @@ -217,7 +218,10 @@ class DownloadService: if path_str in (dl_result.quarantined_paths or []): continue path = Path(path_str) - if not path.exists(): + # Sync stdlib filesystem ops are intentional here: this orchestrator + # runs under `asyncio.run` inside a Celery task — no other awaitables + # compete for the loop. ASYNC240 suppressed below. + if not path.exists(): # noqa: ASYNC240 continue def _attach(p=path): @@ -230,7 +234,7 @@ class DownloadService: if result.status in ("imported", "superseded"): import_summary["attached"] += 1 try: - bytes_downloaded += path.stat().st_size + bytes_downloaded += path.stat().st_size # noqa: ASYNC240 except OSError: pass elif result.status == "skipped" and result.skip_reason and result.skip_reason.value in ( @@ -238,7 +242,7 @@ class DownloadService: ): import_summary["skipped"] += 1 try: - path.unlink(missing_ok=True) + path.unlink(missing_ok=True) # noqa: ASYNC240 except OSError: pass else: diff --git a/backend/app/services/file_validator.py b/backend/app/services/file_validator.py index 791b142..ca6e40f 100644 --- a/backend/app/services/file_validator.py +++ b/backend/app/services/file_validator.py @@ -14,7 +14,6 @@ from __future__ import annotations from dataclasses import dataclass from pathlib import Path - JPEG_HEAD = b"\xff\xd8\xff" JPEG_TAIL = b"\xff\xd9" diff --git a/backend/app/services/gallery_dl.py b/backend/app/services/gallery_dl.py index eb37a2f..5e9b17f 100644 --- a/backend/app/services/gallery_dl.py +++ b/backend/app/services/gallery_dl.py @@ -19,7 +19,7 @@ import tempfile import time from dataclasses import dataclass, field from datetime import UTC, datetime -from enum import Enum +from enum import StrEnum from pathlib import Path from .file_validator import is_validatable, validate_file @@ -27,7 +27,7 @@ from .file_validator import is_validatable, validate_file log = logging.getLogger(__name__) -class ErrorType(str, Enum): +class ErrorType(StrEnum): AUTH_ERROR = "auth_error" RATE_LIMITED = "rate_limited" NOT_FOUND = "not_found" @@ -655,6 +655,6 @@ class GalleryDLService: ) finally: try: - Path(temp_config_path).unlink() + Path(temp_config_path).unlink() # noqa: ASYNC240 except Exception: pass