add __ne__ support to enum types for input

This commit is contained in:
John McCardle 2026-02-06 21:43:52 -05:00
commit 322beeaf78
5 changed files with 46 additions and 6 deletions

View file

@ -217,6 +217,14 @@ def _Key_eq(self, other):
return int.__eq__(int(self), other)
Key.__eq__ = _Key_eq
def _Key_ne(self, other):
result = type(self).__eq__(self, other)
if result is NotImplemented:
return result
return not result
Key.__ne__ = _Key_ne
Key.__hash__ = lambda self: hash(int(self))
Key.__repr__ = lambda self: f"{type(self).__name__}.{self.name}"
Key.__str__ = lambda self: self.name