Add an __eq__ method to Identity
This commit is contained in:
@@ -58,6 +58,17 @@ class Identity:
|
||||
def __repr__(self) -> str:
|
||||
return f'<Identity {self}>'
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
if isinstance(other, str):
|
||||
return str(self) == other
|
||||
|
||||
if isinstance(other, Identity):
|
||||
return str(self) == str(other)
|
||||
|
||||
raise TypeError(
|
||||
'Don’t know how to compare {self.__class__.__name__} and {other.__class__.__name__}'
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_address(cls, address: str) -> 'Identity':
|
||||
"""Load an identity from an author address"""
|
||||
|
Reference in New Issue
Block a user