Skip to content

Commit 317e3cd

Browse files
committed
Improve CyclicInt type
1 parent 58407db commit 317e3cd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dpath/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ def __new__(cls, value: int, max_value: int, *args, **kwargs):
1818
return obj
1919

2020
def __eq__(self, other):
21+
if not isinstance(other, int):
22+
return False
23+
2124
return int(self) == (self.max_value + other) % self.max_value
2225

2326
def __repr__(self):
24-
return f"<CyclicInt {int(self)}/{self.max_value}>"
27+
return f"<CyclicInt {int(self)}%{self.max_value}>"
2528

2629
def __str__(self):
2730
return str(int(self))

0 commit comments

Comments
 (0)