Skip to content

Commit cb75d2b

Browse files
authored
pybricks.parameters: make Colors hashable.
The MicroPython implementation support hashing, we this should too.
1 parent 32ff42d commit cb75d2b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/pybricks/parameters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ def __repr__(self):
125125
def __eq__(self, other: Color) -> bool:
126126
return self.h == other.h and self.s == other.s and self.v == other.v
127127

128+
def __hash__(self) -> int:
129+
return hash((self.h, self.s, self.v))
130+
128131
def __mul__(self, scale: float) -> Color:
129132
v = max(0, min(self.v * scale, 100))
130133
return Color(self.h, self.s, int(v))

0 commit comments

Comments
 (0)