Skip to content

Commit

Permalink
Fix cached property recursion problem
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Feb 29, 2024
1 parent ef624e9 commit da3b508
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion trakt/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ class ListEntry:
def item(self):
# Poor man's cached_property
if self.type not in self.__dict__:
self.__dict__[self.type] = getattr(self, self.type)
# Avoid recursion
error = object()
self.__dict__[self.type] = error
value = getattr(self, self.type, None)
if value is error:
raise RuntimeError(f"Invalid type: {self.type}")
self.__dict__[self.type] = value

return self.__dict__[self.type]

Expand Down

0 comments on commit da3b508

Please sign in to comment.