refactor(api): code-review fixes — widen iso() to date, fix import order (R6 S1a)

/code-review high round 1 (5 findings):
- iso(dt) now typed `date | None` — MediaAsset.upload_date is a plain `date`, not a
  datetime; the helper's signature was too narrow for the type-contract epic. +test.
- restore alphabetical app.* import order in audit.py and plex.py (the new iso/_common
  imports had been dropped in mid-block).
The other 3 findings are deliberate design choices, left as-is for UAT: push/push-plan
now gate write-scope before the 404 (dependency ordering); the unified 403 message; and
owned_or_404's owner_attr kept for S1b's DownloadShare.to_user_id-style owners.

Gate: ruff clean, pytest 164 green.
This commit is contained in:
2026-07-26 04:25:40 +02:00
parent c5533b0ac5
commit cf8bbad8a1
4 changed files with 16 additions and 10 deletions
+2 -2
View File
@@ -41,16 +41,16 @@ from app.models import (
PlexState,
User,
)
from app.routes._common import owned_or_404
from app.utils import iso
from app.plex import paths as plex_paths
from app.plex import people as plex_people
from app.plex import stream as plex_stream
from app.plex import sync as plex_sync
from app.plex import watch_sync as plex_watch
from app.plex.client import PlexClient, PlexError, PlexNotConfigured
from app.routes._common import owned_or_404
from app.routes.admin import admin_user
from app.routes.feed import _to_tsquery_str
from app.utils import iso
log = logging.getLogger("siftlode.plex")