style: apply ruff format across backend + scripts (line-length 100)

Mechanical, whole-tree `ruff format` pass — no behaviour change. Recorded in
.git-blame-ignore-revs (next commit) so git blame skips it.
This commit is contained in:
2026-08-23 07:43:06 +02:00
parent 434a98d6ed
commit b1832afd18
217 changed files with 3149 additions and 1744 deletions
+32 -7
View File
@@ -9,6 +9,7 @@ rich-fetch time and served from the DB row instead of a live plex.metadata() cal
The endpoint tests use the DB lane (`db` fixture) — skipped when no Postgres is reachable.
"""
from types import SimpleNamespace
from fastapi.testclient import TestClient
@@ -37,7 +38,11 @@ RICH_META = {
"studio": "Paramount",
"tagline": "An offer you can't refuse.",
"Role": [
{"tag": "Marlon Brando", "role": "Vito Corleone", "thumb": "https://metadata-static.plex.tv/b.jpg"},
{
"tag": "Marlon Brando",
"role": "Vito Corleone",
"thumb": "https://metadata-static.plex.tv/b.jpg",
},
{"tag": "Al Pacino", "role": "Michael"},
],
}
@@ -45,6 +50,7 @@ RICH_META = {
# ---- pure parse/persist --------------------------------------------------------------------------
def test_rich_detail_prefers_imdb_entry_and_builds_link():
d = detail.rich_detail(RICH_META)
assert d["imdb_rating"] == 8.7 # the imdb Rating entry, not audienceRating (9.9)
@@ -83,6 +89,7 @@ def test_apply_rich_detail_empty_cast_persists_null():
# ---- backfill persistence (DB lane) --------------------------------------------------------------
class _StubClient:
"""Stand-in for PlexClient: `_enrich_people_batch` calls plex.metadata(rating_key); item_detail
uses it as a context manager and passes markers=True. `raise_` simulates a Plex outage."""
@@ -108,7 +115,10 @@ def test_apply_facet_fields_preserves_enriched_cast_names():
sync never clears people_enriched_at, nothing would regrow it and the person-page filter would lose
the names past the listing cap (regression guard for E5 S5b's enrich gating)."""
# The cheap listing's top few cast + the (always-present) director.
thin = {"Role": [{"tag": "Al Pacino"}, {"tag": "James Caan"}], "Director": [{"tag": "Francis Ford Coppola"}]}
thin = {
"Role": [{"tag": "Al Pacino"}, {"tag": "James Caan"}],
"Director": [{"tag": "Francis Ford Coppola"}],
}
# Not-yet-enriched row: the listing cast IS applied.
fresh = SimpleNamespace(people_enriched_at=None, directors=None, cast_names=None)
@@ -117,6 +127,7 @@ def test_apply_facet_fields_preserves_enriched_cast_names():
# Enriched row: the fuller stored cast is KEPT, not overwritten by the thin listing.
from datetime import datetime, timezone
enriched = SimpleNamespace(
people_enriched_at=datetime.now(timezone.utc),
directors=["Francis Ford Coppola"],
@@ -179,6 +190,7 @@ def test_enrich_people_batch_persists_detail(db):
# ---- item_detail serving (DB lane) ---------------------------------------------------------------
def _get(db, user, monkeypatch, path):
monkeypatch.setattr(state, "_configured_cache", True) # pass the request gate
app.dependency_overrides[get_db] = lambda: db
@@ -203,10 +215,18 @@ def test_item_detail_movie_serves_from_row_despite_live_outage(db, monkeypatch):
db.add(lib)
db.flush()
from datetime import datetime, timezone
mv = PlexItem(
rating_key="m1", library_id=lib.id, kind="movie", title="The Godfather",
genres=["Crime", "Drama"], directors=["Francis Ford Coppola"], studio="Paramount",
content_rating="R", imdb_rating=8.7, imdb_id="tt0068646",
rating_key="m1",
library_id=lib.id,
kind="movie",
title="The Godfather",
genres=["Crime", "Drama"],
directors=["Francis Ford Coppola"],
studio="Paramount",
content_rating="R",
imdb_rating=8.7,
imdb_id="tt0068646",
tagline="An offer you can't refuse.",
full_cast=[{"name": "Marlon Brando", "role": "Vito Corleone", "thumb": None}],
people_enriched_at=datetime.now(timezone.utc),
@@ -283,9 +303,14 @@ def test_show_detail_serves_from_row(db, monkeypatch):
db.add(lib)
db.flush()
from datetime import datetime, timezone
show = PlexShow(
rating_key="s1", library_id=lib.id, title="A Show", genres=["Drama"],
imdb_rating=9.1, imdb_id="tt0903747",
rating_key="s1",
library_id=lib.id,
title="A Show",
genres=["Drama"],
imdb_rating=9.1,
imdb_id="tt0903747",
full_cast=[{"name": "Bryan Cranston", "role": "Walter White", "thumb": None}],
people_enriched_at=datetime.now(timezone.utc),
)