style: run ruff format over the codebase

This commit is contained in:
imSp4rky
2026-07-15 14:49:27 -06:00
parent d853ef9600
commit e31e60a418
39 changed files with 492 additions and 186 deletions
+9 -2
View File
@@ -15,8 +15,15 @@ from types import SimpleNamespace
import pytest
from unshackle.core.cdm import loader as loader_mod
from unshackle.core.cdm.detect import (cdm_location, is_local_cdm, is_playready_cdm, is_remote_cdm,
is_remote_playready_cdm, is_remote_widevine_cdm, is_widevine_cdm)
from unshackle.core.cdm.detect import (
cdm_location,
is_local_cdm,
is_playready_cdm,
is_remote_cdm,
is_remote_playready_cdm,
is_remote_widevine_cdm,
is_widevine_cdm,
)
from unshackle.core.cdm.loader import _stamp_remote
pytestmark = pytest.mark.unit
+1
View File
@@ -16,6 +16,7 @@ from typing import Any, Optional
from uuid import UUID
import pytest
# lxml.etree: XML parser used to build ContentProtection fixtures for DASH.get_drm
from lxml import etree
+7 -2
View File
@@ -9,8 +9,13 @@ from pathlib import Path
import pytest
from unshackle.core.utilities import (close_debug_logger, get_debug_logger, init_debug_logger, log_event,
timed_operation)
from unshackle.core.utilities import (
close_debug_logger,
get_debug_logger,
init_debug_logger,
log_event,
timed_operation,
)
from unshackle.core.utils.redact import redact_all, redact_path, redact_text, redact_url, safe_display_url
from unshackle.core.utils.subprocess import log_tool_run
+18 -6
View File
@@ -12,12 +12,24 @@ import struct
import pytest
from unshackle.core.manifests.ism_init import (NAL_START_CODE, PIFF_SENC_UUID, box, build_avcc, build_dec3,
build_hvcc, build_init_segment, full_box,
parse_codec_private_data_colour, parse_codec_private_data_vui,
parse_hevc_sps_format, read_per_sample_iv_size, read_track_id,
remove_emulation_prevention, split_nal_units,
synthesize_aac_codec_private_data)
from unshackle.core.manifests.ism_init import (
NAL_START_CODE,
PIFF_SENC_UUID,
box,
build_avcc,
build_dec3,
build_hvcc,
build_init_segment,
full_box,
parse_codec_private_data_colour,
parse_codec_private_data_vui,
parse_hevc_sps_format,
read_per_sample_iv_size,
read_track_id,
remove_emulation_prevention,
split_nal_units,
synthesize_aac_codec_private_data,
)
# Real CodecPrivateData taken from a Smooth Streaming manifest.
VIDEO_HEVC_CPD = (
+2 -2
View File
@@ -4,11 +4,11 @@ undecidable from the manifest; the post-mux bitstream probe names it."""
from __future__ import annotations
from tests.core.test_ism_init import VIDEO_HEVC10_CPD, VIDEO_HEVC_DV_CPD, VIDEO_HEVC_PQ_CPD, VIDEO_HEVC_SDR_CPD
from unshackle.core.manifests import ISM
from unshackle.core.tracks import Video
from tests.core.test_ism_init import (VIDEO_HEVC10_CPD, VIDEO_HEVC_DV_CPD, VIDEO_HEVC_HLG_CPD, # isort: skip
VIDEO_HEVC_PQ_CPD, VIDEO_HEVC_SDR_CPD)
from tests.core.test_ism_init import VIDEO_HEVC_HLG_CPD # isort: skip
def manifest_xml(cpd: str, fourcc: str = "HVC1") -> str:
+25 -5
View File
@@ -12,8 +12,14 @@ from typing import Any, Optional
from rich.console import Console, RenderableType
from rich.panel import Panel
from unshackle.core.music.display import (MusicHeaderInfo, TrackRow, format_track_detail_quality, render_album_header,
render_artwork_preview, render_track_panel)
from unshackle.core.music.display import (
MusicHeaderInfo,
TrackRow,
format_track_detail_quality,
render_album_header,
render_artwork_preview,
render_track_panel,
)
from unshackle.core.titles.music import Song
@@ -97,8 +103,20 @@ def test_format_track_detail_quality_passthrough() -> None:
def test_render_track_panel_returns_panel() -> None:
rows = [
TrackRow(song=make_song(track=1, name="First"), quality_label="FLAC 16-bit/44.1kHz", layout="Stereo", duration_str="3:00", cd=True),
TrackRow(song=make_song(track=2, name="Second"), quality_label="OGG 320", layout="Stereo", duration_str="4:00", hires=True),
TrackRow(
song=make_song(track=1, name="First"),
quality_label="FLAC 16-bit/44.1kHz",
layout="Stereo",
duration_str="3:00",
cd=True,
),
TrackRow(
song=make_song(track=2, name="Second"),
quality_label="OGG 320",
layout="Stereo",
duration_str="4:00",
hires=True,
),
]
panel = render_track_panel(rows, total=len(rows))
assert isinstance(panel, Panel)
@@ -112,7 +130,9 @@ def test_render_track_panel_returns_panel() -> None:
def test_render_track_panel_singular_label() -> None:
rows = [TrackRow(song=make_song(name="Only"), quality_label="FLAC 16-bit/44.1kHz", layout="Stereo", duration_str="3:00")]
rows = [
TrackRow(song=make_song(name="Only"), quality_label="FLAC 16-bit/44.1kHz", layout="Stereo", duration_str="3:00")
]
text = render_to_text(render_track_panel(rows, total=1))
# The count node reads "1 Track" (singular); the panel title is always
# "Available Tracks", so we only check the count node phrasing here.
+11 -3
View File
@@ -6,9 +6,17 @@ from typing import Any, Optional
import pytest
from unshackle.core.music.extract import (build_music_from_songs, classify_release_kind, dedupe_track_options,
duration_seconds, first_number, first_text, format_duration, format_names,
year_from_value)
from unshackle.core.music.extract import (
build_music_from_songs,
classify_release_kind,
dedupe_track_options,
duration_seconds,
first_number,
first_text,
format_duration,
format_names,
year_from_value,
)
from unshackle.core.music.models import MusicTrackOption
from unshackle.core.titles.music import Music, Song
+1 -3
View File
@@ -115,9 +115,7 @@ def hand_built_ctx(body: dict[str, Any]) -> click.Context:
ctx = click.Context(parsed.command)
ctx.params = {"repack": body.get("repack", False)}
for name in ctx.params:
ctx.set_parameter_source(
name, ParameterSource.COMMANDLINE if name in body else ParameterSource.DEFAULT
)
ctx.set_parameter_source(name, ParameterSource.COMMANDLINE if name in body else ParameterSource.DEFAULT)
return ctx
+1 -3
View File
@@ -240,9 +240,7 @@ def test_refresh_reports_discarded_local_edits(monkeypatch, tmp_path):
def test_changed_services_up_to_date(monkeypatch):
monkeypatch.setattr(service_repo.binaries, "Git", "git")
# same HEAD before/after → no diff computed at all
monkeypatch.setattr(
service_repo.subprocess, "run", lambda *a, **k: pytest.fail("no git diff when HEAD unchanged")
)
monkeypatch.setattr(service_repo.subprocess, "run", lambda *a, **k: pytest.fail("no git diff when HEAD unchanged"))
assert service_repo._changed_services(Path("/x"), "same", "same") == []