--- /dev/null
+# Tweepy
+# Copyright 2009-2020 Joshua Roesslein
+# See LICENSE for details.
+
+class EqualityComparable:
+ __slots__ = ()
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.id == other.id
+
+ return NotImplemented
+
+
+class Hashable(EqualityComparable):
+ __slots__ = ()
+
+ def __hash__(self):
+ return self.id
# Copyright 2009-2020 Joshua Roesslein
# See LICENSE for details.
+from tweepy.mixins import Hashable
from tweepy.utils import parse_a_href, parse_datetime, parse_html_value
return '%s(%s)' % (self.__class__.__name__, ', '.join(state))
-class Status(Model):
+class Status(Model, Hashable):
@classmethod
def parse(cls, api, json):
def favorite(self):
return self._api.create_favorite(self.id)
- def __eq__(self, other):
- if isinstance(other, Status):
- return self.id == other.id
- return NotImplemented
-
-
-class User(Model):
+class User(Model, Hashable):
@classmethod
def parse(cls, api, json):
*args,
**kwargs)
- def __eq__(self, other):
- if isinstance(other, User):
- return self.id == other.id
-
- return NotImplemented
-
- def __hash__(self):
- return self.id
-
class DirectMessage(Model):