From f8c13367f1c37607e0159950b957bb4b559cf6f2 Mon Sep 17 00:00:00 2001 From: Henrijs Date: Tue, 4 Jun 2024 16:44:01 +0300 Subject: [PATCH] Fix linting --- custom_components/trakt_tv/const.py | 11 ++--------- custom_components/trakt_tv/models/media.py | 8 ++++++-- custom_components/trakt_tv/utils.py | 7 ++++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/custom_components/trakt_tv/const.py b/custom_components/trakt_tv/const.py index d82b154..32c7ee6 100644 --- a/custom_components/trakt_tv/const.py +++ b/custom_components/trakt_tv/const.py @@ -172,13 +172,6 @@ "zu", ] -SORT_BY_OPTIONS = [ - "rating", - "rating_trakt", - "rank", - "runtime", - "released", - "listed_at" -] +SORT_BY_OPTIONS = ["rating", "rating_trakt", "rank", "runtime", "released", "listed_at"] -SORT_HOW_OPTIONS = ["asc", "desc"] \ No newline at end of file +SORT_HOW_OPTIONS = ["asc", "desc"] diff --git a/custom_components/trakt_tv/models/media.py b/custom_components/trakt_tv/models/media.py index 58e01a7..41ab329 100644 --- a/custom_components/trakt_tv/models/media.py +++ b/custom_components/trakt_tv/models/media.py @@ -283,14 +283,18 @@ def to_homeassistant(self) -> Dict[str, Any]: class Medias: items: List[Media] - def to_homeassistant(self, sort_by = 'released', sort_order = 'asc') -> Dict[str, Any]: + def to_homeassistant(self, sort_by="released", sort_order="asc") -> Dict[str, Any]: """ Convert the List of medias to recommendation data. :return: The dictionary containing all necessary information for upcoming media card """ - medias = sorted(self.items, key=lambda media: getattr(media, sort_by), reverse=sort_order == "desc") + medias = sorted( + self.items, + key=lambda media: getattr(media, sort_by), + reverse=sort_order == "desc", + ) medias = [media.to_homeassistant() for media in medias] return [first_item] + medias diff --git a/custom_components/trakt_tv/utils.py b/custom_components/trakt_tv/utils.py index 5067edd..5f0373e 100644 --- a/custom_components/trakt_tv/utils.py +++ b/custom_components/trakt_tv/utils.py @@ -93,8 +93,13 @@ def cache_retrieve(cache: Dict[str, Any], key: str) -> Optional[Any]: else: return None + def parse_utc_date(date_str: Optional[str]) -> Optional[datetime]: """ Parse an ISO date string (all dates returned from Trakt) to a datetime object. """ - return datetime.fromisoformat(date_str).replace(tzinfo=timezone.utc) if date_str else None \ No newline at end of file + return ( + datetime.fromisoformat(date_str).replace(tzinfo=timezone.utc) + if date_str + else None + )