Skip to content

Commit e33a116

Browse files
committed
Fix incompatible override for the "less than" special method
Pylance flagged a reportIncompatibleMethodOverride.
1 parent 07807e9 commit e33a116

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

iso639/iso639.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ def __hash__(self):
168168
def __eq__(self, other):
169169
return type(other) is type(self) and hash(other) == hash(self)
170170

171-
def __lt__(self, other):
172-
return (
173-
type(other) is type(self) and other.name and self.name < other.name
174-
)
171+
def __lt__(self, other) -> bool:
172+
for i in range(min(len(self), len(other))):
173+
if self[i] < other[i]:
174+
return True
175+
elif self[i] > other[i]:
176+
return False
177+
return len(self) < len(other)
175178

176179
def __getnewargs__(self):
177180
unpickling_args = (self.name,)

0 commit comments

Comments
 (0)