-
Notifications
You must be signed in to change notification settings - Fork 580
Open
Description
Hello,
I'm not sure how to describe the issue, so here is a sample code
from rdflib import FOAF, Graph, Literal, URIRef
class MyId(URIRef): ...
g = Graph()
g.add((MyId("subject"), FOAF.name, Literal("bob")))
print(g.serialize())
assert (MyId("subject"), FOAF.name, Literal("bob")) in g # ok
assert (URIRef("subject"), FOAF.name, Literal("bob")) in g # failsAnd the output
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<subject> foaf:name "bob" .I was expecting the second assert to be True because in both case I'm looking for the subject <subject>.
PS: on the why I'm subclassing URIRef, it's to leverage static type checking with mypy when my functions are expecting ids that carry a special meaning.
Is it the expected behavior and should I take care of always passing URIRef object ?
This fix the issue but is a bit cumbersome.
g.add((URIRef(MyId("subject")), FOAF.name, Literal("bob")))
print(g.serialize())
assert (URIRef(MyId("subject")), FOAF.name, Literal("bob")) in g # ok
assert (URIRef("subject"), FOAF.name, Literal("bob")) in g # okMetadata
Metadata
Assignees
Labels
No labels