Skip to content

Commit 4cf2180

Browse files
Reduce warnings (#3087)
* build(deps-dev): bump ruff from 0.9.2 to 0.9.6 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.2 to 0.9.6. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](astral-sh/ruff@0.9.2...0.9.6) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * add readthedocs sphynx.configuration * replace ConjunctiveGraph() with Dataset() in tests * tidy some notation * align black version * fix black & ruff * poetry --check -> poetry-check --lock * more CG -> Datasets * ruff * GC -> Dataset * CG -> D * ruff fixes --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 8bbb30d commit 4cf2180

File tree

8 files changed

+28
-25
lines changed

8 files changed

+28
-25
lines changed

test/test_graph/test_aggregate_graphs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from io import StringIO
22

3-
from rdflib import logger, plugin
4-
from rdflib.graph import ConjunctiveGraph, Graph, ReadOnlyGraphAggregate
3+
from rdflib import Dataset, Graph, logger, plugin
4+
from rdflib.graph import ReadOnlyGraphAggregate
55
from rdflib.namespace import RDF, RDFS
66
from rdflib.store import Store
77
from rdflib.term import URIRef
@@ -108,10 +108,10 @@ def test_aggregate2():
108108

109109
graph4 = Graph(mem_store, RDFS)
110110
graph4.parse(data=TEST_GRAPH_1N3, format="n3")
111-
g = ConjunctiveGraph(mem_store)
111+
g = Dataset(store=mem_store, default_union=True)
112112
assert g is not None
113113
assert len(list(g.quads((None, None, None, None)))) == 11
114-
assert len(list(g.contexts())) == 4
114+
assert len(list(g.contexts())) == 5
115115
logger.debug(list(g.contexts()))
116116
assert (
117117
len(list(g.quads((None, None, None, URIRef("http://example.com/graph2"))))) == 4

test/test_graph/test_graph_context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import pytest
1111

12-
from rdflib import BNode, ConjunctiveGraph, Graph, URIRef, plugin
12+
from rdflib import BNode, Dataset, Graph, URIRef, plugin
1313
from rdflib.store import Store
1414

1515

@@ -20,7 +20,7 @@ class ContextTestCase(unittest.TestCase):
2020

2121
def setUp(self):
2222
try:
23-
self.graph = ConjunctiveGraph(store=self.store)
23+
self.graph = Dataset(store=self.store, default_union=True)
2424
except ImportError:
2525
pytest.skip("Dependencies for store '%s' not available!" % self.store)
2626
if self.store == "SQLite":
@@ -337,8 +337,11 @@ def test_triples(self):
337337
)
338338
asserte(set(c.subject_predicates(michel)), {(bob, hates)})
339339

340+
d = set()
341+
for x in c:
342+
d.add(x[0:3])
340343
asserte(
341-
set(c),
344+
set(d),
342345
{
343346
(bob, hates, michel),
344347
(bob, likes, cheese),

test/test_issues/test_issue535.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from rdflib import ConjunctiveGraph, URIRef
1+
from rdflib import Dataset, URIRef
22

33

44
def test_nquads_default_graph():
5-
ds = ConjunctiveGraph()
5+
ds = Dataset(default_union=True)
66

77
data = """
88
<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .

test/test_namespace/test_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def add_not_in_namespace(s):
232232
# a property name within the FOAF namespace
233233
assert FOAF.givenName == URIRef("http://xmlns.com/foaf/0.1/givenName")
234234

235-
# namescape can be used as str
235+
# namespace can be used as str
236236
assert FOAF.givenName.startswith(FOAF)
237237

238238
def test_contains_method(self):

test/test_parsers/test_broken_parse_data_from_jena.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ def xfail_broken_parse_data(request):
3333
@pytest.mark.parametrize("testfile", os.listdir(broken_parse_data))
3434
@pytest.mark.usefixtures("xfail_broken_parse_data")
3535
def test_n3_serializer_roundtrip(testfile) -> None:
36-
g1 = rdflib.ConjunctiveGraph()
36+
g1 = rdflib.Dataset(default_union=True)
3737

3838
g1.parse(os.path.join(broken_parse_data, testfile), format="n3")

test/test_serializers/test_prettyxml.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from io import BytesIO
22

3-
from rdflib.graph import ConjunctiveGraph
3+
from rdflib.graph import Dataset
44
from rdflib.namespace import RDF, RDFS
55
from rdflib.plugins.serializers.rdfxml import PrettyXMLSerializer
66
from rdflib.term import BNode, Literal, URIRef
@@ -10,7 +10,7 @@ class SerializerTestBase:
1010
repeats = 8
1111

1212
def setup_method(self):
13-
graph = ConjunctiveGraph()
13+
graph = Dataset()
1414
graph.parse(data=self.test_content, format=self.test_content_format)
1515
self.source_graph = graph
1616

@@ -41,12 +41,12 @@ def _assert_equal_graphs(g1, g2):
4141

4242
def _mangled_copy(g):
4343
"Makes a copy of the graph, replacing all bnodes with the bnode ``_blank``."
44-
gcopy = ConjunctiveGraph()
44+
gcopy = Dataset()
4545

4646
def isbnode(v):
4747
return isinstance(v, BNode)
4848

49-
for s, p, o in g:
49+
for s, p, o, c in g:
5050
if isbnode(s):
5151
s = _blank
5252
if isbnode(p):
@@ -67,7 +67,7 @@ def serialize(source_graph, make_serializer, get_value=True, extra_args={}):
6767
def serialize_and_load(source_graph, make_serializer):
6868
stream = serialize(source_graph, make_serializer, False)
6969
stream.seek(0)
70-
reparsed_graph = ConjunctiveGraph()
70+
reparsed_graph = Dataset()
7171
reparsed_graph.parse(stream, format="xml")
7272
return reparsed_graph
7373

@@ -170,7 +170,7 @@ def test_subclass_of_objects(self):
170170

171171
def test_pretty_xmlliteral(self):
172172
# given:
173-
g = ConjunctiveGraph()
173+
g = Dataset()
174174
g.add(
175175
(
176176
BNode(),
@@ -191,7 +191,7 @@ def test_pretty_xmlliteral(self):
191191

192192
def test_pretty_broken_xmlliteral(self):
193193
# given:
194-
g = ConjunctiveGraph()
194+
g = Dataset()
195195
g.add((BNode(), RDF.value, Literal("""<p """, datatype=RDF.XMLLiteral)))
196196
# when:
197197
xmlrepr = g.serialize(format="pretty-xml")
@@ -203,7 +203,7 @@ def test_pretty_broken_xmlliteral(self):
203203

204204

205205
def _assert_expected_object_types_for_predicates(graph, predicates, types):
206-
for s, p, o in graph:
206+
for s, p, o, c in graph:
207207
if p in predicates:
208208
some_true = [isinstance(o, t) for t in types]
209209
assert (

test/test_serializers/test_serializer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import rdflib
3131
import rdflib.plugin
3232
from rdflib import RDF, XSD, Graph, Literal, Namespace, URIRef
33-
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID, ConjunctiveGraph, Dataset
33+
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID, Dataset
3434
from rdflib.serializer import Serializer
3535
from test.utils import GraphHelper, get_unique_plugins
3636
from test.utils.destination import DestinationType, DestParmType, DestRef
@@ -54,7 +54,7 @@
5454
)
5555
def test_rdf_type(format: str, tuple_index: int, is_keyword: bool) -> None:
5656
NS = Namespace("example:") # noqa: N806
57-
graph = ConjunctiveGraph()
57+
graph = Dataset(default_union=True)
5858
graph.bind("eg", NS)
5959
nodes = [NS.subj, NS.pred, NS.obj, NS.graph]
6060
nodes[tuple_index] = RDF.type
@@ -68,7 +68,7 @@ def test_rdf_type(format: str, tuple_index: int, is_keyword: bool) -> None:
6868
assert str(RDF) not in data
6969
else:
7070
assert str(RDF) in data
71-
parsed_graph = ConjunctiveGraph()
71+
parsed_graph = Dataset(default_union=True)
7272
parsed_graph.parse(data=data, format=format)
7373
GraphHelper.assert_triple_sets_equals(graph, parsed_graph)
7474

test/test_store/test_store_sparqlupdatestore_mock.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import ClassVar
22

3-
from rdflib.graph import ConjunctiveGraph
3+
from rdflib.graph import Dataset
44
from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
55
from test.utils.http import MethodName, MockHTTPResponse
66
from test.utils.httpservermock import ServedBaseHTTPServerMock
@@ -33,7 +33,7 @@ def teardown_method(self):
3333
pass
3434

3535
def test_graph_update(self):
36-
graph = ConjunctiveGraph("SPARQLUpdateStore")
36+
graph = Dataset("SPARQLUpdateStore")
3737
graph.open((self.query_endpoint, self.update_endpoint))
3838
update_statement = (
3939
f"INSERT DATA {{ {EGDO['subj']} {EGDO['pred']} {EGDO['obj']}. }}"
@@ -58,7 +58,7 @@ def test_graph_update(self):
5858
assert "application/sparql-update" in req.headers.get("content-type")
5959

6060
def test_update_encoding(self):
61-
graph = ConjunctiveGraph("SPARQLUpdateStore")
61+
graph = Dataset("SPARQLUpdateStore")
6262
graph.open((self.query_endpoint, self.update_endpoint))
6363
update_statement = (
6464
f"INSERT DATA {{ {EGDO['subj']} {EGDO['pred']} {EGDO['obj']}. }}"

0 commit comments

Comments
 (0)