Skip to content

Commit

Permalink
Adjust behaviour in #1481 to return NotImplemented
Browse files Browse the repository at this point in the history
  • Loading branch information
weaversam8 committed Oct 25, 2024
1 parent 3ac48c1 commit 9d35d1b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
6 changes: 1 addition & 5 deletions lark/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ def __init__(self, name: str) -> None:
self.name = name

def __eq__(self, other):
if other is None:
return False
if not isinstance(other, Symbol):
raise NotImplementedError(
f"Comparing a Symbol with type {type(other).__name__} is not implemented"
)
return NotImplemented
return self.is_term == other.is_term and self.name == other.name

def __ne__(self, other):
Expand Down
8 changes: 0 additions & 8 deletions tests/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,6 @@ def test_symbol_eq(self):

self.assertNotEqual(a, b)

a = dict()

self.assertRaisesRegex(
NotImplementedError,
r"Comparing a Symbol with type dict is not implemented",
lambda: a == b,
)


if __name__ == '__main__':
main()

0 comments on commit 9d35d1b

Please sign in to comment.