Add __eq__ and __hash__ to NamedUser (#706)

* Add __eq__ and __hash__ to NamedUser

* Remove extra outer brackets from __eq__ in NamedUser

* Add unit tests for __eq__ and __hash__

* Remove redundant brackets in __eq__ : NamedUser
This commit is contained in:
namc
2018-02-21 14:40:01 +08:00
committed by Wan Liuyang
parent 0e5a1d1d53
commit 8a13b27476
3 changed files with 34 additions and 0 deletions
+6
View File
@@ -46,6 +46,12 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
def __repr__(self):
return self.get__repr__({"login": self._login.value})
def __hash__(self):
return hash((self.id, self.login))
def __eq__(self, other):
return isinstance(other, type(self)) and self.login == other.login and self.id == other.id
@property
def avatar_url(self):
"""