Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions proto/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def _comparable(self, other):
# Avoid 'isinstance' to prevent other IntEnums from matching
return type(other) in (type(self), int)

def __hash__(self):
return hash(self.value)

def __eq__(self, other):
if not self._comparable(other):
return NotImplemented
Expand Down
6 changes: 6 additions & 0 deletions tests/test_enum_total_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@ def test_total_ordering_w_int(int_val):
assert to_compare <= int_val
assert not to_compare > int_val
assert to_compare >= int_val


def test_hashing():
to_hash = enums_test.OneEnum.SOME_VALUE

{to_hash: "testing"} # no raise