Skip to content

Commit

Permalink
Add str for Rating class
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Feb 22, 2024
1 parent c500a1f commit 6e6575c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plextraktsync/util/Rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from datetime import datetime, timezone
from typing import NamedTuple

from trakt.utils import timestamp


class Rating(NamedTuple):
rating: int | None
Expand All @@ -12,6 +14,9 @@ def __eq__(self, other):
""" Ratings are equal if their rating value is the same """
return self.rating == other.rating

def __str__(self):
return f"Rating(rating={self.rating}, rated_at='{timestamp(self.rated_at)}')"

@classmethod
def create(cls, rating: int | float | None, rated_at: datetime | str | None):
if rating is None:
Expand Down

0 comments on commit 6e6575c

Please sign in to comment.