refactor(types): bring mypy to zero errors across unshackle

Fix the bugs the type errors exposed (RnetSession.send body, HLS proxy session, title cache fallback, mux progress) and gate mypy in pre-commit, warn-only in CI.
This commit is contained in:
imSp4rky
2026-10-30 20:51:21 -06:00
parent b493c9cd52
commit 7898ff6dd6
95 changed files with 810 additions and 589 deletions
+2 -2
View File
@@ -213,7 +213,7 @@ class Episode(Title):
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
if folder:
template = config.get_folder_template("series")
template: Optional[str] = config.get_folder_template("series")
if template:
# all parts of an episode land in the same season folder
context = self.build_template_context(media_info, show_service, include_part=False)
@@ -268,7 +268,7 @@ class Episode(Title):
class Series(SortedKeyList, ABC):
def __init__(self, iterable: Optional[Iterable] = None):
def __init__(self, iterable: Optional[Iterable] = None) -> None:
# part slots before year so existing ties still resolve by year
super().__init__(iterable, key=lambda x: (x.season, x.number, x.part or 0, x.year or 0))
+2 -2
View File
@@ -61,7 +61,7 @@ class Movie(Title):
def get_filename(self, media_info: MediaInfo, folder: bool = False, show_service: bool = True) -> str:
if folder:
template = config.get_folder_template("movies")
template: Optional[str] = config.get_folder_template("movies")
if template:
context = self.build_template_context(media_info, show_service)
spacer = detect_spacer(template) # one style for the whole path
@@ -86,7 +86,7 @@ class Movie(Title):
class Movies(SortedKeyList, ABC):
def __init__(self, iterable: Optional[Iterable] = None):
def __init__(self, iterable: Optional[Iterable] = None) -> None:
super().__init__(iterable, key=lambda x: x.year or 0)
def __str__(self) -> str:
+2 -2
View File
@@ -230,7 +230,7 @@ class Song(Title):
class Music(SortedKeyList, ABC):
"""A grouped music release, such as an album, EP, single, compilation, or playlist."""
def __new__(cls, *args: Any, **kwargs: Any):
def __new__(cls, *args: Any, **kwargs: Any) -> "Music":
return super().__new__(cls)
def __init__(
@@ -246,7 +246,7 @@ class Music(SortedKeyList, ABC):
total_duration: Optional[int] = None,
owner: Optional[str] = None,
description: Optional[str] = None,
):
) -> None:
if not isinstance(kind, str):
raise TypeError(f"Expected kind to be a str, not {kind!r}")
if title is not None and not isinstance(title, str):
+4 -2
View File
@@ -58,13 +58,15 @@ class Title:
self.id = id_
self.service = service
self.language = language
self.data = data
self.data: Any = data
self.anime: Optional[bool] = None
self.daily: Optional[bool] = None
self.tracks = Tracks()
def __eq__(self, other: Title) -> bool:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Title):
return NotImplemented
return self.id == other.id
def build_base_template_context(self, media_info: MediaInfo, show_service: bool = True) -> dict: