Skip to content

Commit 9d35d1b

Browse files
committed
Adjust behaviour in #1481 to return NotImplemented
1 parent 3ac48c1 commit 9d35d1b

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

lark/grammar.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ def __init__(self, name: str) -> None:
1616
self.name = name
1717

1818
def __eq__(self, other):
19-
if other is None:
20-
return False
2119
if not isinstance(other, Symbol):
22-
raise NotImplementedError(
23-
f"Comparing a Symbol with type {type(other).__name__} is not implemented"
24-
)
20+
return NotImplemented
2521
return self.is_term == other.is_term and self.name == other.name
2622

2723
def __ne__(self, other):

tests/test_grammar.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,6 @@ def test_symbol_eq(self):
302302

303303
self.assertNotEqual(a, b)
304304

305-
a = dict()
306-
307-
self.assertRaisesRegex(
308-
NotImplementedError,
309-
r"Comparing a Symbol with type dict is not implemented",
310-
lambda: a == b,
311-
)
312-
313305

314306
if __name__ == '__main__':
315307
main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy