update __eq__ method

Co-authored-by: Oleg A. <t0rr@mail.ru>
This commit is contained in:
darksidecat 2022-06-26 13:52:02 +03:00 committed by GitHub
parent cc0bbd8983
commit 7c18036af0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,7 +55,11 @@ class State:
return raw_state == self.state
def __eq__(self, other):
return self.state == other.state
if isinstance(other, self.__class__):
return self.state == other.state
if isinstance(other, str):
return self.state == other
raise ValueError(f"Comparing {type(self)} and {type(other)} is not supported")
def __hash__(self):
return hash(self.state)