Repository: RDFLib/rdflib

Issue:
Resolve .term.Statement deprecation
`.term.Statement` has been deprecated since 2012. Is there any plan to actually remove it or un-deprecate it?

https://github.com/RDFLib/rdflib/blob/master/rdflib/term.py#L1699

Comments:

Patch:
diff --git a/rdflib/store.py b/rdflib/store.py
index 96390171..44c01e28 100644
--- a/rdflib/store.py
+++ b/rdflib/store.py
@@ -158,7 +158,6 @@ class Store(object):
             from rdflib.term import Literal
             from rdflib.graph import Graph, QuotedGraph
             from rdflib.term import Variable
-            from rdflib.term import Statement
 
             self.__node_pickler = np = NodePickler()
             np.register(self, "S")
@@ -168,7 +167,6 @@ class Store(object):
             np.register(Graph, "G")
             np.register(QuotedGraph, "Q")
             np.register(Variable, "V")
-            np.register(Statement, "s")
         return self.__node_pickler
 
     node_pickler = property(__get_node_pickler)
diff --git a/rdflib/term.py b/rdflib/term.py
index 796a76b3..9f2255e5 100644
--- a/rdflib/term.py
+++ b/rdflib/term.py
@@ -32,7 +32,6 @@ __all__ = [
     "BNode",
     "Literal",
     "Variable",
-    "Statement",
 ]
 
 import logging
@@ -446,7 +445,7 @@ class BNode(Identifier):
         if basepath is None:
             basepath = rdflib_skolem_genid
         skolem = "%s%s" % (basepath, str(self))
-        return URIRef(urljoin(authority, skolem))
+        return RDFLibGenid(urljoin(authority, skolem))
 
 
 class Literal(Identifier):
@@ -1739,24 +1738,6 @@ class Variable(Identifier):
         return (Variable, (str(self),))
 
 
-class Statement(Node, tuple):
-    def __new__(cls, triple, context):
-        subject, predicate, object = triple
-        warnings.warn(
-            "Class Statement is deprecated, and will be removed in "
-            + "the future. If you use this please let rdflib-dev know!",
-            category=DeprecationWarning,
-            stacklevel=2,
-        )
-        return tuple.__new__(cls, ((subject, predicate, object), context))
-
-    def __reduce__(self):
-        return (Statement, (self[0], self[1]))
-
-    def toPython(self):
-        return (self[0], self[1])
-
-
 # Nodes are ordered like this
 # See http://www.w3.org/TR/sparql11-query/#modOrderBy
 # we leave "space" for more subclasses of Node elsewhere


Test patch:
diff --git a/test/test_980.py b/test/test_980.py
new file mode 100644
index 00000000..3c60a849
--- /dev/null
+++ b/test/test_980.py
@@ -0,0 +1,28 @@
+from rdflib import Graph
+
+
+def test_980():
+    """
+    The problem that this test ensures rdflib solves is that, previous to PR #1108, the
+    parsing of two triples with the same n-triples Blank Nodes IDs, here _:0, would
+    result in triples with the same rdflib internal BN IDs, e.g.
+    rdflib.term.BNode('Ne3fd8261b37741fca22d502483d88964'), see the Issue #980. They
+    should have different IDs.
+    """
+    graph1 = """
+    _:0 <http://purl.obolibrary.org/obo/RO_0002350> <http://www.gbif.org/species/0000001> .
+    """
+    graph2 = """
+    _:0 <http://purl.obolibrary.org/obo/RO_0002350> <http://www.gbif.org/species/0000002> .
+    """
+
+    g = Graph()
+    g.parse(data=graph1, format="nt")
+    g.parse(data=graph2, format="nt")
+
+    subs = 0
+    for s in g.subjects(None, None):
+        subs += 1
+
+    # we must see two different BN subjects
+    assert subs == 2
diff --git a/test/test_issue1404.py b/test/test_issue1404.py
new file mode 100644
index 00000000..469f713e
--- /dev/null
+++ b/test/test_issue1404.py
@@ -0,0 +1,42 @@
+from rdflib import Graph, URIRef, FOAF
+from rdflib.term import RDFLibGenid
+from rdflib.compare import isomorphic
+
+
+def test_skolem_de_skolem_roundtrip():
+    """Test round-trip of skolemization/de-skolemization of data.
+
+    Issue: https://github.com/RDFLib/rdflib/issues/1404
+    """
+
+    ttl = '''
+    @prefix wd: <http://www.wikidata.org/entity/> .
+    @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+
+    wd:Q1203 foaf:knows [ a foaf:Person;
+        foaf:name "Ringo" ].
+    '''
+
+    graph = Graph()
+    graph.parse(data=ttl, format='turtle')
+
+    query = {"subject": URIRef("http://www.wikidata.org/entity/Q1203"), "predicate": FOAF.knows}
+
+    # Save the original bnode id.
+    bnode_id = graph.value(**query)
+
+    skolemized_graph = graph.skolemize()
+
+    # Check the BNode is now an RDFLibGenid after skolemization.
+    skolem_bnode = skolemized_graph.value(**query)
+    assert type(skolem_bnode) == RDFLibGenid
+
+    # Check that the original bnode id exists somewhere in the uri.
+    assert bnode_id in skolem_bnode
+
+    # Check that the original data is not isomorphic with the skolemized data.
+    assert not isomorphic(graph, skolemized_graph)
+
+    # Check that the original graph data is the same as the de-skolemized data.
+    de_skolemized_graph = skolemized_graph.de_skolemize()
+    assert isomorphic(graph, de_skolemized_graph)