Remove singly-used alias obviated by IdentifiedNode by ajnelson-nist · Pull Request #1695 · RDFLib/rdflib (original) (raw)
I think the best options here are:
- Remove
ContextNode
andDatasetQuad
and changeDataset.__iter__
as follow:
- def iter(self) -> Generator[DatasetQuad, None, None]:
- def iter(self) -> Generator[Tuple[Node, URIRef, Node, Optional[Node]], None, None]:
This captures the current reality of what is advertised in Graph
(though URIRef
is also another issue, we should probably narrow the types accepted by Graph.add
to match this)
2. Remove ContextNode
and DatasetQuad
and change Graph.__init__
as follow:
diff --git a/rdflib/graph.py b/rdflib/graph.py
index 6d1ed084..55005574 100644
--- a/rdflib/graph.py
+++ b/rdflib/graph.py
@@ -325,7 +325,7 @@ class Graph(Node):
def init(
self,
store: Union[Store, str] = "default",
identifier: Optional[Union[Node, str]] = None,
):identifier: Optional[Union[IdentifiedNode, str]] = None, namespace_manager: Optional[NamespaceManager] = None, base: Optional[str] = None,
And then changeDataset.__iter__
as follow:
- def iter(self) -> Generator[DatasetQuad, None, None]:
- def iter(self) -> Generator[Tuple[Node, URIRef, Node, Optional[IdentifiedNode]], None, None]:
I somewhat favor option 2, as I think this is the more correct thing to do. We don't want to advertise to people that they should be passing values in as graph identifiers that are not inline with RDF 1.1 - and if they still want to they can use type ignores.