diff options
| author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2019-07-22 10:53:21 +0100 |
|---|---|---|
| committer | Benjamin Schubert <contact@benschubert.me> | 2019-07-26 09:03:34 +0100 |
| commit | 8b77cb608cb5bdbb51deb213b6a66083f3070734 (patch) | |
| tree | f2c88c9f6d6df43d9f0a17e0908cd363dbd83957 | |
| parent | 86c848f356868baebe0872550fb78e0b9cb65c2e (diff) | |
| download | buildstream-8b77cb608cb5bdbb51deb213b6a66083f3070734.tar.gz | |
dropme? Add __{eq,ne,hash}__ to FastEnum
Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
| -rw-r--r-- | src/buildstream/_types.pyx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/buildstream/_types.pyx b/src/buildstream/_types.pyx index e08eef700..fe3cb41e2 100644 --- a/src/buildstream/_types.pyx +++ b/src/buildstream/_types.pyx @@ -73,3 +73,16 @@ class FastEnum(metaclass=MetaFastEnum): if type(self) != type(other): return NotImplemented return self.value >= other.value + + def __eq__(self, other): + if type(self) != type(other): + raise ValueError + return self.value == other.value + + def __ne__(self, other): + if type(self) != type(other): + raise ValueError + return self.value != other.value + + def __hash__(self): + return self.__str__().__hash__() |
