Skip to content

Commit 69e5990

Browse files
authored
Implement __hash__ and __eq__ methods in IdentifiedNode
1 parent 72a98ed commit 69e5990

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rdflib/term.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ class IdentifiedNode(Identifier):
269269

270270
__slots__ = ()
271271

272+
def __hash__(self) -> int:
273+
return super().__hash__()
274+
275+
def __eq__(self, other: Any) -> bool:
276+
if isinstance(other, IdentifiedNode):
277+
return self.n3() == other.n3() # compare the N3 notation and not the string representation
278+
return super().__eq__(other)
279+
272280
def n3(self, namespace_manager: NamespaceManager | None = None) -> str:
273281
raise NotImplementedError()
274282

0 commit comments

Comments
 (0)