Skip to content

Commit 2856f65

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 7cb7381 commit 2856f65

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

rdflib/graph.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ def add_to_cbd_original(uri):
16381638

16391639
def add_to_cbd_reverse(uri):
16401640
for s, p, o in self.triples((None, None, uri)):
1641-
1641+
16421642
subgraph.add((s, p, o))
16431643
# recurse 'down' through ll Blank Nodes
16441644
if type(s) == BNode and not (s, None, None) in subgraph:
@@ -1653,14 +1653,15 @@ def add_to_cbd_reverse(uri):
16531653
for s, p, o in self.triples((None, RDF.object, uri)):
16541654
# find all triples with s as the subject and add these to the subgraph
16551655
for s2, p2, o2 in self.triples((s, None, None)):
1656-
1656+
16571657
subgraph.add((s2, p2, o2))
16581658

16591659
add_to_cbd_original(resource)
16601660
add_to_cbd_reverse(resource)
16611661

16621662
return subgraph
16631663

1664+
16641665
class ConjunctiveGraph(Graph):
16651666
"""A ConjunctiveGraph is an (unnamed) aggregation of all the named
16661667
graphs in a store.

rdflib/plugins/sparql/algebra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,15 +777,15 @@ def translateQuery(q, base=None, initNs=None):
777777
q[1], visitPost=functools.partial(translatePName, prologue=prologue)
778778
)
779779

780-
if(q[1].name!= "DescribeQuery"):
780+
if q[1].name != "DescribeQuery":
781781
P, PV = translate(q[1])
782782
datasetClause = q[1].datasetClause
783783
if q[1].name == "ConstructQuery":
784784

785785
template = triples(q[1].template) if q[1].template else None
786786

787787
res = CompValue(q[1].name, p=P, template=template, datasetClause=datasetClause)
788-
elif(q[1].name== "DescribeQuery"):
788+
elif q[1].name == "DescribeQuery":
789789
res = CompValue(q[1].name, p=None, datasetClause=datasetClause, PV=q[1].var)
790790
else:
791791
res = CompValue(q[1].name, p=P, datasetClause=datasetClause, PV=PV)

rdflib/plugins/sparql/evaluate.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,12 @@ def evalPart(ctx: QueryContext, part: CompValue):
294294
# raise Exception('ServiceGraphPattern not implemented')
295295

296296
elif part.name == "DescribeQuery":
297-
subgraph = Graph()
297+
subgraph = Graph()
298298
for var in part['PV']:
299299
subgraph = ctx.graph.describe_cbd(var, subgraph)
300-
res = {"type_": "DESCRIBE", "graph": subgraph}
301-
302-
return res
300+
res = {"type_": "DESCRIBE", "graph": subgraph}
303301

302+
return res
304303

305304
else:
306305
raise Exception("I dont know: %s" % part.name)

test/test_graph/test_graph_cbd.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ def testCbdReified(get_graph):
110110

111111
assert len(g.cbd(EX.R6)) == (3 + 5 + 5), "cbd() for R6 should return 12 triples"
112112

113+
113114
def testCbdDescribeReified(get_graph):
114115
g = get_graph
115-
#Checking DESCRIBE query
116+
# Checking DESCRIBE query
116117
g.parse(
117118
data="""
118119
PREFIX ex: <http://ex/>
@@ -148,10 +149,12 @@ def testCbdDescribeReified(get_graph):
148149
""",
149150
format="turtle",
150151
)
151-
#print(len(g.describe_cbd(EX.R5,Graph())))
152+
# print(len(g.describe_cbd(EX.R5,Graph())))
152153
# this cbd() call should get the 3 basic triples with ex:R5 as subject as well as 5 more from the reified
153154
# statement
154-
assert len(g.describe_cbd(EX.R5,Graph())) == (3 + 5 + 8), "describe_cbd() for R5 should return 16 triples"
155+
assert len(g.describe_cbd(EX.R5, Graph())) == (
156+
3 + 5 + 8
157+
), "describe_cbd() for R5 should return 16 triples"
155158

156159
# add crazy reified triples to the testing graph
157160
g.parse(
@@ -191,5 +194,7 @@ def testCbdDescribeReified(get_graph):
191194
""",
192195
format="turtle",
193196
)
194-
#print(len(g.describe_cbd(EX.R6)))
195-
assert len(g.describe_cbd(EX.R6, Graph())) == (3 + 5 + 5 + 2), "describe_cbd() for R6 should return 15 triples"
197+
# print(len(g.describe_cbd(EX.R6)))
198+
assert len(g.describe_cbd(EX.R6, Graph())) == (
199+
3 + 5 + 5 + 2
200+
), "describe_cbd() for R6 should return 15 triples"

0 commit comments

Comments
 (0)