RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

TypeError: Param.postParse2() missing 1 required positional argument: 'tokenList' when executing a SPARQL query with RDFLib 7.0 #2821

Closed alame14 closed 2 months ago

alame14 commented 2 months ago

When executing a SPARQL query using the query() method in RDFLib 7.0, a TypeError: Param.postParse2() missing 1 required positional argument: 'tokenList' error is raised. This error did not occur in previous versions of RDFLib, such as version 6.2.

from rdflib import Graph, Namespace, RDF

# Graph
g = Graph()
c = Namespace("http://example.org/c/")
rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
g.bind("c", c)
g.bind("rdf", rdf)

# Add triples to the graph
g.add((c.Individual1, RDF.type, c.SomeClass))
g.add((c.Individual2, RDF.type, c.SomeClass))
g.add((c.Individual3, RDF.type, c.AnotherClass))

# Define the SPARQL query
my_query = """
    PREFIX c: <http://example.org/c/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    SELECT ?s WHERE { ?s rdf:type c:SomeClass }
"""

# Execute the query
results = g.query(my_query)
for row in results:
    print(f"Subject: {row.s}")

Environment

Expected Behavior

The SPARQL query should execute correctly, returning subjects of type c:SomeClass without raising any errors.

Observed Behavior

Executing the script raises the following error: Error: Param.postParse2() missing 1 required positional argument: 'tokenList'

Additional Comments

This error does not occur with RDFLib 6.2, suggesting the issue is specific to version 7.0 of the library.

Workaround

Use RDFLib 6.2 until this issue is resolved.

alame14 commented 2 months ago

I'm closing this issue, because I was mistaken about the version I originally thought I was using. Probably a problem with my environment. Tested with version 7.0, and result ok.