Return early in TraktApi.rating()
@@ -147,12 +147,11 @@ def rating(self, m) -> Optional[int]:
However, the Movie property is always None.
So fetch for all types.
"""
- if m.media_type in ["movies", "shows", "episodes"]:
- r = self.ratings[m.media_type]
- return r.get(m.trakt, None)
- else:
+ if m.media_type not in ["movies", "shows", "episodes"]:
raise ValueError(f"Unsupported type: {m.media_type}")
+ return self.ratings[m.media_type].get(m.trakt, None)
+
@rate_limit()
@retry()
def get_ratings(self, media_type: str):
