diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py
index f194a7f0f..0f64806d1 100644
--- a/rdflib/namespace/__init__.py
+++ b/rdflib/namespace/__init__.py
@@ -238,7 +238,7 @@ def __getattr__(cls, name: str):
return cls.__getitem__(name)
def __repr__(cls) -> str:
- return f'Namespace({str(cls._NS)!r})'
+ return f"Namespace({str(cls._NS)!r})"
def __str__(cls) -> str:
return str(cls._NS)
@@ -275,9 +275,9 @@ def as_jsonld_context(self, pfx: str) -> dict:
terms = {pfx: str(self._NS)}
for key, term in self.__annotations__.items():
if issubclass(term, URIRef):
- terms[key] = f'{pfx}:{key}'
+ terms[key] = f"{pfx}:{key}"
- return {'@context': terms}
+ return {"@context": terms}
class DefinedNamespace(metaclass=DefinedNamespaceMeta):
diff --git a/rdflib/parser.py b/rdflib/parser.py
index ceee51d4e..f535361fa 100644
--- a/rdflib/parser.py
+++ b/rdflib/parser.py
@@ -197,14 +197,14 @@ class URLInputSource(InputSource):
links: List[str]
@classmethod
- def getallmatchingheaders(cls, message: 'HTTPMessage', name):
+ def getallmatchingheaders(cls, message: "HTTPMessage", name):
# This is reimplemented here, because the method
# getallmatchingheaders from HTTPMessage is broken since Python 3.0
name = name.lower()
return [val for key, val in message.items() if key.lower() == name]
@classmethod
- def get_links(cls, response: 'HTTPResponse'):
+ def get_links(cls, response: "HTTPResponse"):
linkslines = cls.getallmatchingheaders(response.headers, "Link")
retarray = []
for linksline in linkslines:
@@ -214,8 +214,8 @@ def get_links(cls, response: 'HTTPResponse'):
return retarray
def get_alternates(self, type_: Optional[str] = None) -> List[str]:
- typestr: Optional[str] = f"type=\"{type_}\"" if type_ else None
- relstr = "rel=\"alternate\""
+ typestr: Optional[str] = f'type="{type_}"' if type_ else None
+ relstr = 'rel="alternate"'
alts = []
for link in self.links:
parts = [p.strip() for p in link.split(";")]
diff --git a/rdflib/plugins/sparql/algebra.py b/rdflib/plugins/sparql/algebra.py
index 5d7dac330..0bff336d5 100644
--- a/rdflib/plugins/sparql/algebra.py
+++ b/rdflib/plugins/sparql/algebra.py
@@ -964,7 +964,7 @@ def sparql_query_text(node):
)
aggr_vars[agg_func.res].append(agg_func.vars)
- agg_func_name = agg_func.name.split('_')[1]
+ agg_func_name = agg_func.name.split("_")[1]
distinct = ""
if agg_func.distinct:
distinct = agg_func.distinct + " "
diff --git a/rdflib/util.py b/rdflib/util.py
index b73a95942..328a87430 100644
--- a/rdflib/util.py
+++ b/rdflib/util.py
@@ -194,9 +194,9 @@ def from_n3(s: str, default=None, backend=None, nsm=None):
return Literal(s == "true")
elif (
s.lower()
- .replace('.', '', 1)
- .replace('-', '', 1)
- .replace('e', '', 1)
+ .replace(".", "", 1)
+ .replace("-", "", 1)
+ .replace("e", "", 1)
.isnumeric()
):
if "e" in s.lower():
diff --git a/test/jsonld/runner.py b/test/jsonld/runner.py
index 9826bca93..13afc0851 100644
--- a/test/jsonld/runner.py
+++ b/test/jsonld/runner.py
@@ -41,9 +41,9 @@ def make_fake_urlinputsource(input_uri, format=None, suite_base=None, options={}
if "httpLink" in options:
source.links.append(options["httpLink"])
if "contentType" in options:
- source.content_type = options['contentType']
+ source.content_type = options["contentType"]
if "redirectTo" in options:
- redir = suite_base + options['redirectTo']
+ redir = suite_base + options["redirectTo"]
local_redirect = redir.replace(
"https://w3c.github.io/json-ld-api/tests/", "./"
)
diff --git a/test/test_graph/test_namespace_rebinding.py b/test/test_graph/test_namespace_rebinding.py
index f76216e5a..f83da974a 100644
--- a/test/test_graph/test_namespace_rebinding.py
+++ b/test/test_graph/test_namespace_rebinding.py
@@ -34,7 +34,7 @@ def test_binding_replace():
g.bind("foaf", FOAF1)
g.bind("foaf2", FOAF2)
assert len(list(g.namespaces())) == 2
- assert list(g.namespaces()) == [('foaf', foaf1_uri), ("foaf2", foaf2_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri), ("foaf2", foaf2_uri)]
# Now you want to "upgrade" to FOAF2=>foaf and try the obvious:
g.bind("foaf", FOAF2)
@@ -61,7 +61,7 @@ def test_binding_replace():
assert list(g.namespaces()) == [
("foaf", foaf2_uri), # Should be present but has been removed.
- ('oldfoaf', foaf1_uri),
+ ("oldfoaf", foaf1_uri),
]
# 2. Changing the prefix of an existing namespace=>prefix binding:
@@ -72,7 +72,7 @@ def test_binding_replace():
# Which, as things stand, results in:
- assert list(g.namespaces()) == [("foaf", foaf2_uri), ('foaf1', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf2_uri), ("foaf1", foaf1_uri)]
# In which the attempted change from `oldfoaf` to (the already
# bound-to-a different-namespace `foaf`) was intercepted and
@@ -82,13 +82,13 @@ def test_binding_replace():
g.bind("oldfoaf", FOAF1, replace=True)
# The bindings are again as desired
- assert list(g.namespaces()) == [("foaf", foaf2_uri), ('oldfoaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf2_uri), ("oldfoaf", foaf1_uri)]
# Next time through, set override to False
g.bind("foaf", FOAF1, override=False)
# And the bindings will remain as desired
- assert list(g.namespaces()) == [("foaf", foaf2_uri), ('oldfoaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf2_uri), ("oldfoaf", foaf1_uri)]
# 3. Parsing data with prefix=>namespace bindings
# Let's see the situation regarding namespace bindings
@@ -108,7 +108,7 @@ def test_binding_replace():
# non-clashing prefix of `foaf1` is rebound to FOAF1 in
# place of the existing `oldfoaf` prefix
- assert list(g.namespaces()) == [("foaf", foaf2_uri), ('foaf1', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf2_uri), ("foaf1", foaf1_uri)]
# Yes, namespace bindings in parsed data replace existing
# bindings (i.e. `oldfoaf` was replaced by `foaf1`), just
@@ -128,7 +128,7 @@ def test_binding_replace():
# by the `foaf2=>FOAF2` binding specified in the N3 source
assert list(g.namespaces()) == [
- ('foaf1', foaf1_uri),
+ ("foaf1", foaf1_uri),
("foaf2", foaf2_uri),
]
@@ -146,7 +146,7 @@ def test_binding_replace():
# used
assert list(g.namespaces()) == [
- ('foaf1', foaf1_uri),
+ ("foaf1", foaf1_uri),
("foaf2", foaf2_uri),
]
@@ -161,7 +161,7 @@ def test_binding_replace():
assert list(g.namespaces()) == [
("foaf2", foaf2_uri),
- ('foaf', foaf1_uri),
+ ("foaf", foaf1_uri),
]
# Prefixes are bound to namespaces which in turn have a URIRef
@@ -191,11 +191,11 @@ def test_prefix_alias_disallowed():
g = Graph(bind_namespaces="none")
g.bind("owl", OWL)
- assert ('owl', URIRef('http://www.w3.org/2002/07/owl#')) in list(g.namespaces())
+ assert ("owl", URIRef("http://www.w3.org/2002/07/owl#")) in list(g.namespaces())
g.bind("wol", OWL, override=False)
- assert ('owl', URIRef('http://www.w3.org/2002/07/owl#')) in list(g.namespaces())
- assert ('wol', URIRef('http://www.w3.org/2002/07/owl#')) not in list(g.namespaces())
+ assert ("owl", URIRef("http://www.w3.org/2002/07/owl#")) in list(g.namespaces())
+ assert ("wol", URIRef("http://www.w3.org/2002/07/owl#")) not in list(g.namespaces())
def test_rebind_prefix_succeeds():
@@ -204,11 +204,11 @@ def test_rebind_prefix_succeeds():
g = Graph(bind_namespaces="none")
g.bind("owl", OWL)
- assert ('owl', URIRef('http://www.w3.org/2002/07/owl#')) in list(g.namespaces())
+ assert ("owl", URIRef("http://www.w3.org/2002/07/owl#")) in list(g.namespaces())
g.bind("wol", OWL)
- assert ('wol', URIRef('http://www.w3.org/2002/07/owl#')) in list(g.namespaces())
- assert ('owl', URIRef('http://www.w3.org/2002/07/owl#')) not in list(g.namespaces())
+ assert ("wol", URIRef("http://www.w3.org/2002/07/owl#")) in list(g.namespaces())
+ assert ("owl", URIRef("http://www.w3.org/2002/07/owl#")) not in list(g.namespaces())
def test_parse_rebinds_prefix():
@@ -223,14 +223,14 @@ def test_parse_rebinds_prefix():
# Use full set of namespace bindings, including foaf
g = Graph(bind_namespaces="none")
- g.bind('foaf', FOAF1)
- assert ('foaf', foaf1_uri) in list(g.namespaces())
+ g.bind("foaf", FOAF1)
+ assert ("foaf", foaf1_uri) in list(g.namespaces())
g.parse(data=data, format="n3")
# foaf no longer in set of namespace bindings
- assert ('foaf', foaf1_uri) not in list(g.namespaces())
- assert ('friend-of-a-friend', foaf1_uri) in list(g.namespaces())
+ assert ("foaf", foaf1_uri) not in list(g.namespaces())
+ assert ("friend-of-a-friend", foaf1_uri) in list(g.namespaces())
@pytest.mark.xfail(
@@ -254,7 +254,7 @@ def test_automatic_handling_of_unknown_predicates():
g = Graph(bind_namespaces="none")
- g.add((tarek, URIRef('http://xmlns.com/foaf/0.1/name'), Literal("Tarek")))
+ g.add((tarek, URIRef("http://xmlns.com/foaf/0.1/name"), Literal("Tarek")))
assert len(list(g.namespaces())) > 0
@@ -263,7 +263,7 @@ def test_automatic_handling_of_unknown_predicates_only_effected_after_serializat
g = Graph(bind_namespaces="none")
- g.add((tarek, URIRef('http://xmlns.com/foaf/0.1/name'), Literal("Tarek")))
+ g.add((tarek, URIRef("http://xmlns.com/foaf/0.1/name"), Literal("Tarek")))
assert "@prefix ns1: ." in g.serialize(format="n3")
@@ -282,27 +282,27 @@ def test_multigraph_bindings():
g1 = Graph(store, identifier=context1, bind_namespaces="none")
- g1.bind('foaf', FOAF1)
- assert list(g1.namespaces()) == [('foaf', foaf1_uri)]
- assert list(store.namespaces()) == [('foaf', foaf1_uri)]
+ g1.bind("foaf", FOAF1)
+ assert list(g1.namespaces()) == [("foaf", foaf1_uri)]
+ assert list(store.namespaces()) == [("foaf", foaf1_uri)]
g1.add((tarek, FOAF1.name, Literal("tarek")))
- assert list(store.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(store.namespaces()) == [("foaf", foaf1_uri)]
g2 = Graph(store, identifier=context2, bind_namespaces="none")
g2.parse(data=data, format="n3")
# The parser-caused rebind is in the underlying store and all objects
# that use the store see the changed binding:
- assert list(store.namespaces()) == [('friend-of-a-friend', foaf1_uri)]
- assert list(g1.namespaces()) == [('friend-of-a-friend', foaf1_uri)]
+ assert list(store.namespaces()) == [("friend-of-a-friend", foaf1_uri)]
+ assert list(g1.namespaces()) == [("friend-of-a-friend", foaf1_uri)]
# Including newly-created objects that use the store
cg = ConjunctiveGraph(store=store)
- assert ('foaf', foaf1_uri) not in list(cg.namespaces())
- assert ('friend-of-a-friend', foaf1_uri) in list(cg.namespaces())
+ assert ("foaf", foaf1_uri) not in list(cg.namespaces())
+ assert ("friend-of-a-friend", foaf1_uri) in list(cg.namespaces())
assert len(list(g1.namespaces())) == 6
assert len(list(g2.namespaces())) == 6
@@ -324,24 +324,24 @@ def test_multigraph_bindings():
# Add foaf2 binding if not already bound
cg.bind("foaf2", FOAF2, override=False)
- assert ('foaf2', foaf2_uri) in list(cg.namespaces())
+ assert ("foaf2", foaf2_uri) in list(cg.namespaces())
# Impose foaf binding ... if not already bound
cg.bind("foaf", FOAF1, override=False)
- assert ('foaf', foaf1_uri) not in list(cg.namespaces())
+ assert ("foaf", foaf1_uri) not in list(cg.namespaces())
def test_new_namespace_new_prefix():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
def test_change_prefix_override_true():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
g.bind("oldfoaf", FOAF1)
# Changed
@@ -352,7 +352,7 @@ def test_change_prefix_override_false():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
g.bind("oldfoaf", FOAF1, override=False)
# No change
@@ -363,7 +363,7 @@ def test_change_namespace_override_true():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
g.bind("foaf", FOAF2)
# Different prefix used
@@ -374,7 +374,7 @@ def test_change_namespace_override_false():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
# Different namespace so override is irrelevant in this case
g.bind("foaf", FOAF2, override=False)
@@ -386,14 +386,14 @@ def test_new_namespace_override_false():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF2)
- assert list(g.namespaces()) == [('foaf', foaf2_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf2_uri)]
# Namespace not already bound so override is irrelevant in this case
g.bind("owl", OWL, override=False)
# Given prefix used
assert list(g.namespaces()) == [
("foaf", foaf2_uri),
- ('owl', URIRef('http://www.w3.org/2002/07/owl#')),
+ ("owl", URIRef("http://www.w3.org/2002/07/owl#")),
]
@@ -406,7 +406,7 @@ def test_change_namespace_and_prefix():
g = Graph(bind_namespaces="none")
g.bind("foaf", FOAF1)
- assert list(g.namespaces()) == [('foaf', foaf1_uri)]
+ assert list(g.namespaces()) == [("foaf", foaf1_uri)]
g.bind("foaf", FOAF2, replace=True)
assert list(g.namespaces()) == [("foaf", foaf2_uri)]
diff --git a/test/test_issues/test_issue1404.py b/test/test_issues/test_issue1404.py
index 309c8ac8e..e6f292340 100644
--- a/test/test_issues/test_issue1404.py
+++ b/test/test_issues/test_issue1404.py
@@ -8,16 +8,16 @@ def test_skolem_de_skolem_roundtrip():
Issue: https://github.com/RDFLib/rdflib/issues/1404
"""
- ttl = '''
+ ttl = """
@prefix wd: .
@prefix foaf: .
wd:Q1203 foaf:knows [ a foaf:Person;
foaf:name "Ringo" ].
- '''
+ """
graph = Graph()
- graph.parse(data=ttl, format='turtle')
+ graph.parse(data=ttl, format="turtle")
query = {
"subject": URIRef("http://www.wikidata.org/entity/Q1203"),
diff --git a/test/test_issues/test_issue1808.py b/test/test_issues/test_issue1808.py
index e5120058f..04f0927a4 100644
--- a/test/test_issues/test_issue1808.py
+++ b/test/test_issues/test_issue1808.py
@@ -17,8 +17,8 @@ def test():
for s, p, o in gs:
assert isinstance(s, URIRef) and s.__contains__(rdflib_skolem_genid)
- query_with_iri = 'select ?p ?o {{ <{}> ?p ?o }}'.format(s)
- query_for_all = 'select ?s ?p ?o { ?s ?p ?o }'
+ query_with_iri = "select ?p ?o {{ <{}> ?p ?o }}".format(s)
+ query_for_all = "select ?s ?p ?o { ?s ?p ?o }"
count = 0
for row in gs.query(query_with_iri):
@@ -31,7 +31,7 @@ def test():
assert count == 1
gp = Graph()
- gp.parse(data=gs.serialize(format='turtle'), format='turtle')
+ gp.parse(data=gs.serialize(format="turtle"), format="turtle")
count = 0
for row in gp.query(query_with_iri):
diff --git a/test/test_literal/test_literal.py b/test/test_literal/test_literal.py
index 8587e5b75..718cc1d09 100644
--- a/test/test_literal/test_literal.py
+++ b/test/test_literal/test_literal.py
@@ -390,80 +390,80 @@ def test_ill_formed_literals(
Literal(datetime.timedelta(days=2)),
),
(
- Literal(datetime.time.fromisoformat('04:23:01.000384')),
+ Literal(datetime.time.fromisoformat("04:23:01.000384")),
Literal(isodate.Duration(hours=1)),
"aplusb",
Literal("05:23:01.000384", datatype=XSD.time),
),
(
- Literal(datetime.date.fromisoformat('2011-11-04')),
+ Literal(datetime.date.fromisoformat("2011-11-04")),
Literal(isodate.Duration(days=1)),
"aplusb",
Literal("2011-11-05", datatype=XSD.date),
),
(
Literal(
- datetime.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
+ datetime.datetime.fromisoformat("2011-11-04 00:05:23.283+00:00")
),
Literal(isodate.Duration(days=1)),
"aplusb",
Literal("2011-11-05T00:05:23.283000+00:00", datatype=XSD.dateTime),
),
(
- Literal(datetime.time.fromisoformat('04:23:01.000384')),
+ Literal(datetime.time.fromisoformat("04:23:01.000384")),
Literal(datetime.timedelta(hours=1)),
"aplusb",
Literal("05:23:01.000384", datatype=XSD.time),
),
(
- Literal(datetime.date.fromisoformat('2011-11-04')),
+ Literal(datetime.date.fromisoformat("2011-11-04")),
Literal(datetime.timedelta(days=1)),
"aplusb",
Literal("2011-11-05", datatype=XSD.date),
),
(
Literal(
- datetime.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
+ datetime.datetime.fromisoformat("2011-11-04 00:05:23.283+00:00")
),
Literal(datetime.timedelta(days=1)),
"aplusb",
Literal("2011-11-05T00:05:23.283000+00:00", datatype=XSD.dateTime),
),
(
- Literal(datetime.time.fromisoformat('04:23:01.000384')),
+ Literal(datetime.time.fromisoformat("04:23:01.000384")),
Literal(isodate.Duration(hours=1)),
"aminusb",
Literal("03:23:01.000384", datatype=XSD.time),
),
(
- Literal(datetime.date.fromisoformat('2011-11-04')),
+ Literal(datetime.date.fromisoformat("2011-11-04")),
Literal(isodate.Duration(days=1)),
"aminusb",
Literal("2011-11-03", datatype=XSD.date),
),
(
Literal(
- datetime.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
+ datetime.datetime.fromisoformat("2011-11-04 00:05:23.283+00:00")
),
Literal(isodate.Duration(days=1)),
"aminusb",
Literal("2011-11-03T00:05:23.283000+00:00", datatype=XSD.dateTime),
),
(
- Literal(datetime.time.fromisoformat('04:23:01.000384')),
+ Literal(datetime.time.fromisoformat("04:23:01.000384")),
Literal(datetime.timedelta(hours=1)),
"aminusb",
Literal("03:23:01.000384", datatype=XSD.time),
),
(
- Literal(datetime.date.fromisoformat('2011-11-04')),
+ Literal(datetime.date.fromisoformat("2011-11-04")),
Literal(datetime.timedelta(days=1)),
"aminusb",
Literal("2011-11-03", datatype=XSD.date),
),
(
Literal(
- datetime.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
+ datetime.datetime.fromisoformat("2011-11-04 00:05:23.283+00:00")
),
Literal(datetime.timedelta(days=1)),
"aminusb",
diff --git a/test/test_literal/test_xmlliterals.py b/test/test_literal/test_xmlliterals.py
index 3c1089113..ca5950855 100644
--- a/test/test_literal/test_xmlliterals.py
+++ b/test/test_literal/test_xmlliterals.py
@@ -102,8 +102,8 @@ def testHTML():
[
pytest.param(
[
- lambda: Literal('', datatype=RDF.XMLLiteral),
- lambda: Literal('', datatype=RDF.XMLLiteral),
+ lambda: Literal("", datatype=RDF.XMLLiteral),
+ lambda: Literal("", datatype=RDF.XMLLiteral),
],
True,
),
diff --git a/test/test_namespace/test_definednamespace.py b/test/test_namespace/test_definednamespace.py
index 622b01914..3a6fdd600 100644
--- a/test/test_namespace/test_definednamespace.py
+++ b/test/test_namespace/test_definednamespace.py
@@ -52,7 +52,7 @@ def test_definednamespace_creator_qb():
if '_NS = Namespace("http://purl.org/linked-data/cube#")' in line:
has_ns = True
if (
- 'Attachable: URIRef # Abstract superclass for everything that can have attributes and dimensions'
+ "Attachable: URIRef # Abstract superclass for everything that can have attributes and dimensions"
in line
):
has_test_class = True
@@ -340,7 +340,7 @@ def test_value(dfns: Type[DefinedNamespace], attr_name: str, is_defined: bool) -
warnings_record = xstack.enter_context(warnings.catch_warnings(record=True))
if dfns_info.suffix is None or (not is_defined and dfns._fail is True):
xstack.enter_context(pytest.raises(AttributeError))
- resolved = eval(f'dfns.{attr_name}')
+ resolved = eval(f"dfns.{attr_name}")
if dfns_info.suffix is not None:
if is_defined or dfns._fail is False:
assert f"{prefix}{dfns_info.suffix}{attr_name}" == f"{resolved}"
diff --git a/test/test_namespace/test_definednamespace_creator.py b/test/test_namespace/test_definednamespace_creator.py
index bc976acaa..65734b217 100644
--- a/test/test_namespace/test_definednamespace_creator.py
+++ b/test/test_namespace/test_definednamespace_creator.py
@@ -41,7 +41,7 @@ def test_definednamespace_creator_qb():
if '_NS = Namespace("http://purl.org/linked-data/cube#")' in line:
has_ns = True
if (
- 'Attachable: URIRef # Abstract superclass for everything that can have attributes and dimensions'
+ "Attachable: URIRef # Abstract superclass for everything that can have attributes and dimensions"
in line
):
has_test_class = True
diff --git a/test/test_namespacemanager.py b/test/test_namespacemanager.py
index 9ee6143aa..4d20d42b4 100644
--- a/test/test_namespacemanager.py
+++ b/test/test_namespacemanager.py
@@ -168,5 +168,5 @@ def test_compute_qname_no_generate() -> None:
g = Graph() # 'core' bind_namespaces (default)
with pytest.raises(KeyError):
g.namespace_manager.compute_qname_strict(
- 'https://example.org/unbound/test', generate=False
+ "https://example.org/unbound/test", generate=False
)
diff --git a/test/test_parsers/test_broken_parse_data_from_jena.py b/test/test_parsers/test_broken_parse_data_from_jena.py
index f9153108f..0c9deb4ea 100644
--- a/test/test_parsers/test_broken_parse_data_from_jena.py
+++ b/test/test_parsers/test_broken_parse_data_from_jena.py
@@ -36,4 +36,4 @@ def test_n3_serializer_roundtrip(testfile) -> None:
g1 = rdflib.ConjunctiveGraph()
- g1.parse(os.path.join(broken_parse_data, testfile), format='n3')
+ g1.parse(os.path.join(broken_parse_data, testfile), format="n3")
diff --git a/test/test_parsers/test_parser_turtlelike.py b/test/test_parsers/test_parser_turtlelike.py
index 0a1babb31..1eac25e1e 100644
--- a/test/test_parsers/test_parser_turtlelike.py
+++ b/test/test_parsers/test_parser_turtlelike.py
@@ -154,8 +154,8 @@ class Case:
"\n": "\\n",
"\r": "\\r",
"\f": "\\f",
- "\"": "\\\"",
- "\'": "\\\'",
+ '"': '\\"',
+ "'": "\\'",
"\\": "\\\\",
}
diff --git a/test/test_serializers/test_serializer_n3.py b/test/test_serializers/test_serializer_n3.py
index 4a008105a..afbdc6395 100644
--- a/test/test_serializers/test_serializer_n3.py
+++ b/test/test_serializers/test_serializer_n3.py
@@ -49,9 +49,9 @@ def test_implies():
graph2 = rdflib.Graph()
graph2.parse(data=graph1.serialize(format="n3"), format="n3")
assert (
- rdflib.term.URIRef('http://test/a'),
- rdflib.term.URIRef('http://test/d'),
- rdflib.term.URIRef('http://test/c'),
+ rdflib.term.URIRef("http://test/a"),
+ rdflib.term.URIRef("http://test/d"),
+ rdflib.term.URIRef("http://test/c"),
) in graph2
diff --git a/test/test_sparql/test_service.py b/test/test_sparql/test_service.py
index c7d67a1a3..8ed09cc89 100644
--- a/test/test_sparql/test_service.py
+++ b/test/test_sparql/test_service.py
@@ -209,15 +209,15 @@ def test_service_node_types():
expected = freeze_bindings(
[
- {Variable('o'): URIRef('http://example.org/URI')},
- {Variable('o'): Literal('Simple Literal')},
+ {Variable("o"): URIRef("http://example.org/URI")},
+ {Variable("o"): Literal("Simple Literal")},
{
- Variable('o'): Literal(
- 'String Literal',
- datatype=URIRef('http://www.w3.org/2001/XMLSchema#string'),
+ Variable("o"): Literal(
+ "String Literal",
+ datatype=URIRef("http://www.w3.org/2001/XMLSchema#string"),
)
},
- {Variable('o'): Literal('String Language', lang='en')},
+ {Variable("o"): Literal("String Language", lang="en")},
]
)
assert expected == freeze_bindings(results.bindings)
@@ -258,15 +258,15 @@ def httpmock(
{"type": "bnode", "value": "ohci6Te6aidooNgo"},
],
[
- URIRef('http://example.org/uri'),
- Literal('literal without type or lang'),
- Literal('literal with lang', lang='en'),
+ URIRef("http://example.org/uri"),
+ Literal("literal without type or lang"),
+ Literal("literal with lang", lang="en"),
Literal(
- 'typed-literal with datatype',
- datatype=URIRef('http://www.w3.org/2001/XMLSchema#string'),
+ "typed-literal with datatype",
+ datatype=URIRef("http://www.w3.org/2001/XMLSchema#string"),
),
- Literal('literal with datatype', datatype=XSD.string),
- BNode('ohci6Te6aidooNgo'),
+ Literal("literal with datatype", datatype=XSD.string),
+ BNode("ohci6Te6aidooNgo"),
],
),
(
diff --git a/test/test_sparql/test_sparql.py b/test/test_sparql/test_sparql.py
index 7af981dd2..d62c345e1 100644
--- a/test/test_sparql/test_sparql.py
+++ b/test/test_sparql/test_sparql.py
@@ -258,28 +258,28 @@ def test_property_bindings(rdfs_graph: Graph) -> None:
)
expected_bindings = [
{
- Variable('class'): RDFS.Class,
- Variable('label'): Literal('Class'),
+ Variable("class"): RDFS.Class,
+ Variable("label"): Literal("Class"),
},
{
- Variable('class'): RDFS.Container,
- Variable('label'): Literal('Container'),
+ Variable("class"): RDFS.Container,
+ Variable("label"): Literal("Container"),
},
{
- Variable('class'): RDFS.ContainerMembershipProperty,
- Variable('label'): Literal('ContainerMembershipProperty'),
+ Variable("class"): RDFS.ContainerMembershipProperty,
+ Variable("label"): Literal("ContainerMembershipProperty"),
},
{
- Variable('class'): RDFS.Datatype,
- Variable('label'): Literal('Datatype'),
+ Variable("class"): RDFS.Datatype,
+ Variable("label"): Literal("Datatype"),
},
{
- Variable('class'): RDFS.Literal,
- Variable('label'): Literal('Literal'),
+ Variable("class"): RDFS.Literal,
+ Variable("label"): Literal("Literal"),
},
{
- Variable('class'): RDFS.Resource,
- Variable('label'): Literal('Resource'),
+ Variable("class"): RDFS.Resource,
+ Variable("label"): Literal("Resource"),
},
]
@@ -499,7 +499,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
}
}
""",
- [{Variable('label'): Literal("The class of classes.")}],
+ [{Variable("label"): Literal("The class of classes.")}],
id="select-optional",
),
pytest.param(
@@ -510,7 +510,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
""",
[
{
- Variable('bound'): Literal(
+ Variable("bound"): Literal(
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
)
}
@@ -523,7 +523,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
BIND( (1+2) as ?bound )
}
""",
- [{Variable('bound'): Literal(3)}],
+ [{Variable("bound"): Literal(3)}],
id="select-bind-plus",
),
pytest.param(
@@ -628,7 +628,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable('bound'): Literal(False)}],
+ [{Variable("bound"): Literal(False)}],
id="select-bind-exists-const-false",
),
pytest.param(
@@ -642,7 +642,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable('bound'): Literal(True)}],
+ [{Variable("bound"): Literal(True)}],
id="select-bind-exists-const-true",
),
pytest.param(
@@ -657,7 +657,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable("s"): RDFS.Class, Variable('bound'): Literal(True)}],
+ [{Variable("s"): RDFS.Class, Variable("bound"): Literal(True)}],
id="select-bind-exists-var-true",
),
pytest.param(
@@ -672,7 +672,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable("s"): RDFS.Class, Variable('bound'): Literal(False)}],
+ [{Variable("s"): RDFS.Class, Variable("bound"): Literal(False)}],
id="select-bind-exists-var-false",
),
pytest.param(
@@ -688,7 +688,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable('bound'): Literal(True)}],
+ [{Variable("bound"): Literal(True)}],
id="select-bind-notexists-const-false",
),
pytest.param(
@@ -702,7 +702,7 @@ def thrower(*args: Any, **kwargs: Any) -> None:
)
}
""",
- [{Variable('bound'): Literal(False)}],
+ [{Variable("bound"): Literal(False)}],
id="select-bind-notexists-const-true",
),
pytest.param(
diff --git a/test/test_sparql/test_translate_algebra.py b/test/test_sparql/test_translate_algebra.py
index 62d352f41..20b23327a 100644
--- a/test/test_sparql/test_translate_algebra.py
+++ b/test/test_sparql/test_translate_algebra.py
@@ -122,12 +122,12 @@ def _format_query(query: str) -> str:
AlgebraTest(
"test_graph_patterns__group_and_substr",
'Test if a query with a variable that is used in the "GROUP BY" clause '
- 'and in the SUBSTR function gets properly translated into the query text.',
+ "and in the SUBSTR function gets properly translated into the query text.",
),
AlgebraTest(
"test_graph_patterns__group_and_nested_concat",
- 'Test if a query with a nested concat expression in the select clause which '
- 'uses a group variable gets properly translated into the query text.',
+ "Test if a query with a nested concat expression in the select clause which "
+ "uses a group variable gets properly translated into the query text.",
),
AlgebraTest(
"test_graph_patterns__having",
diff --git a/test/test_trig.py b/test/test_trig.py
index 71f5ec308..656e65cb9 100644
--- a/test/test_trig.py
+++ b/test/test_trig.py
@@ -87,7 +87,7 @@ def test_blank_graph_identifier():
out = g.serialize(format="trig", encoding="latin-1")
graph_label_line = out.splitlines()[-4]
- assert re.match(br"^_:[a-zA-Z0-9]+ \{", graph_label_line)
+ assert re.match(rb"^_:[a-zA-Z0-9]+ \{", graph_label_line)
def test_graph_parsing():
diff --git a/test/test_w3c_spec/test_rdfxml_w3c.py b/test/test_w3c_spec/test_rdfxml_w3c.py
index cfd940d29..5d299b60b 100644
--- a/test/test_w3c_spec/test_rdfxml_w3c.py
+++ b/test/test_w3c_spec/test_rdfxml_w3c.py
@@ -133,7 +133,7 @@ def _testNegative(uri, manifest):
if isinstance(inDoc, BNode):
inDoc = first(manifest.objects(inDoc, RDFVOC.about))
if verbose:
- write(u"TESTING: %s" % inDoc)
+ write("TESTING: %s" % inDoc)
store = Graph()
test = BNode()