Skip to content

Commit

Permalink
Raise exception in comparison between different types
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarrott committed Sep 22, 2023
1 parent 5ef87c2 commit c1188ca
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pylspclient/lsp_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ def __eq__(self, __value: object) -> bool:
)

def __gt__(self, __value: object) -> bool:
return isinstance(__value, Position) and (self.line, self.character) > (
__value.line,
__value.character,
)
if not isinstance(__value, Position):
raise TypeError(f"Invalid type for comparison: {type(__value).__name__}")
return (self.line, self.character) > (__value.line, __value.character)

def __lt__(self, __value: object) -> bool:
return not self.__eq__(__value) and not self.__gt__(__value)
Expand Down

0 comments on commit c1188ca

Please sign in to comment.