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
+22 -5
View File
@@ -3,6 +3,7 @@
The regression these cover: `Path(info["filepath"] or "")` is `Path(".")`, which PASSES `.exists()`,
so a missing filepath (an arbitrary-URL extractor) skipped the staging fallback and crashed later
with "PosixPath('.') has an empty name" instead of downloading."""
import pytest
from app.downloads.edit import _concat_quote, parse_probe_streams
@@ -23,7 +24,9 @@ class TestProducedFile:
info = {"requested_downloads": [{"filepath": str(tmp_path / "v.mp4")}]}
assert _produced_file(info, staging) == tmp_path / "v.mp4"
@pytest.mark.parametrize("info", [{}, {"requested_downloads": [{}]}, {"requested_downloads": [{"filepath": ""}]}])
@pytest.mark.parametrize(
"info", [{}, {"requested_downloads": [{}]}, {"requested_downloads": [{"filepath": ""}]}]
)
def test_missing_filepath_falls_back_to_staging(self, tmp_path, info):
staging = _staging(tmp_path, "thumb.jpg", "clip.mp4")
assert _produced_file(info, staging) == tmp_path / "clip.mp4"
@@ -62,7 +65,11 @@ class TestProducedFile:
class TestMediaInfo:
def test_playlist_wrapper_unwraps_to_the_entry_that_downloaded(self):
info = {"id": "page", "title": "Article", "entries": [{"id": "vid", "requested_downloads": [{"filepath": "/x.mp4"}]}]}
info = {
"id": "page",
"title": "Article",
"entries": [{"id": "vid", "requested_downloads": [{"filepath": "/x.mp4"}]}],
}
assert _media_info(info)["id"] == "vid"
def test_plain_result_is_untouched(self):
@@ -86,7 +93,11 @@ class TestMediaInfo:
assert _media_info(info)["id"] == "a"
def test_wrapper_that_downloaded_itself_wins_over_its_entries(self):
info = {"id": "vid", "requested_downloads": [{"filepath": "/x.mp4"}], "entries": [{"id": "other"}]}
info = {
"id": "vid",
"requested_downloads": [{"filepath": "/x.mp4"}],
"entries": [{"id": "other"}],
}
assert _media_info(info)["id"] == "vid"
def test_empty_entries_are_ignored(self):
@@ -115,8 +126,14 @@ class TestParseProbeStreams:
assert parse_probe_streams(payload) == ("h264", "opus")
def test_audio_only_and_video_only(self):
assert parse_probe_streams('{"streams":[{"codec_name":"opus","codec_type":"audio"}]}') == (None, "opus")
assert parse_probe_streams('{"streams":[{"codec_name":"av1","codec_type":"video"}]}') == ("av1", None)
assert parse_probe_streams('{"streams":[{"codec_name":"opus","codec_type":"audio"}]}') == (
None,
"opus",
)
assert parse_probe_streams('{"streams":[{"codec_name":"av1","codec_type":"video"}]}') == (
"av1",
None,
)
def test_garbage_is_not_a_crash(self):
assert parse_probe_streams("") == (None, None)