Skip to content

Commit

Permalink
fix: type check in equality operator, no comparison should raise now
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Kozyrenko authored and cdown committed Nov 2, 2023
1 parent df8de24 commit c99d759
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __hash__(self):
return hash(frozenset(vars(self).items()))

def __eq__(self, other):
return other and vars(self) == vars(other)
return isinstance(other, Subtitle) and vars(self) == vars(other)

def __lt__(self, other):
return (self.start, self.end, self.index) < (
Expand Down
3 changes: 2 additions & 1 deletion tests/test_srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ def test_subtitle_inequality(sub_1):


@given(subtitles())
def test_subtitle_inequality_to_none(sub_1):
def test_subtitle_inequality_to_non_matching_type(sub_1):
assert sub_1 != None
assert sub_1 != 1


@given(subtitles())
Expand Down

0 comments on commit c99d759

Please sign in to comment.