fix(fc3c): ruff — split SyncSession import, StrEnum, ASYNC240 noqa, blank-line
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user