From 8e27d1915e3babd766c89a92109452554e568e14 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Sun, 30 May 2021 00:53:46 +0200 Subject: Add mypy to CI pipelines and fix errors it raises --- examples/conjunctive_graphs.py | 8 ++++---- examples/simple_example.py | 8 ++++---- examples/sleepycat_example.py | 2 -- examples/smushing.py | 2 +- examples/sparqlstore_example.py | 4 ++-- examples/swap_primer.py | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) (limited to 'examples') diff --git a/examples/conjunctive_graphs.py b/examples/conjunctive_graphs.py index 289046ec..4088419c 100644 --- a/examples/conjunctive_graphs.py +++ b/examples/conjunctive_graphs.py @@ -43,17 +43,17 @@ if __name__ == "__main__": print("-- %s " % c) # separate graphs - print(gjohn.serialize(format="n3").decode("utf-8")) + print(gjohn.serialize(format="n3")) print("===================") - print(gmary.serialize(format="n3").decode("utf-8")) + print(gmary.serialize(format="n3")) print("===================") # full graph - print(g.serialize(format="n3").decode("utf-8")) + print(g.serialize(format="n3")) # query the conjunction of all graphs xx = None - for x in g[mary : ns.loves / ns.hasCuteName]: + for x in g[mary : ns.loves / ns.hasCuteName]: # type: ignore[misc] xx = x print("Q: Who does Mary love?") print("A: Mary loves {}".format(xx)) diff --git a/examples/simple_example.py b/examples/simple_example.py index 15ae0d81..077382a3 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -39,21 +39,21 @@ if __name__ == "__main__": # Serialize as XML print("--- start: rdf-xml ---") - print(store.serialize(format="pretty-xml").decode("utf-8")) + print(store.serialize(format="pretty-xml")) print("--- end: rdf-xml ---\n") # Serialize as Turtle print("--- start: turtle ---") - print(store.serialize(format="turtle").decode("utf-8")) + print(store.serialize(format="turtle")) print("--- end: turtle ---\n") # Serialize as NTriples print("--- start: ntriples ---") - print(store.serialize(format="nt").decode("utf-8")) + print(store.serialize(format="nt")) print("--- end: ntriples ---\n") # Serialize as JSON-LD # only if you have the JSON-LD plugin installed! print("--- start: JSON-LD ---") - print(store.serialize(format="json-ld").decode("utf-8")) + print(store.serialize(format="json-ld")) print("--- end: JSON-LD ---\n") diff --git a/examples/sleepycat_example.py b/examples/sleepycat_example.py index 1130da0e..484484b9 100644 --- a/examples/sleepycat_example.py +++ b/examples/sleepycat_example.py @@ -39,8 +39,6 @@ if __name__ == "__main__": # close when done, otherwise sleepycat will leak lock entries. graph.close() - graph = None - # reopen the graph graph = ConjunctiveGraph("Sleepycat") diff --git a/examples/smushing.py b/examples/smushing.py index c1c3cb8b..e9ad8f6f 100644 --- a/examples/smushing.py +++ b/examples/smushing.py @@ -42,4 +42,4 @@ if __name__ == "__main__": o = newURI.get(o, o) # might be linked to another person out.add((s, p, o)) - print(out.serialize(format="n3").decode("utf-8")) + print(out.serialize(format="n3")) diff --git a/examples/sparqlstore_example.py b/examples/sparqlstore_example.py index 1d2ed958..986f883c 100644 --- a/examples/sparqlstore_example.py +++ b/examples/sparqlstore_example.py @@ -17,7 +17,7 @@ if __name__ == "__main__": print( "According to DBPedia, Berlin has a population of {0:,}".format( - int(pop), ",d" + int(pop) ).replace(",", ".") ) @@ -27,7 +27,7 @@ if __name__ == "__main__": for p in st.objects(URIRef("http://dbpedia.org/resource/Brisbane"), dbo.populationTotal): print( "According to DBPedia, Brisbane has a population of " - "{0:,}".format(int(pop), ",d") + "{0:,}".format(int(pop)) ) # EXAMPLE 3: doing RDFlib triple navigation using SPARQLStore as a Graph() diff --git a/examples/swap_primer.py b/examples/swap_primer.py index 35dc107c..45327c5f 100644 --- a/examples/swap_primer.py +++ b/examples/swap_primer.py @@ -124,7 +124,7 @@ if __name__ == "__main__": print() print("Printing bigger example as N3:") - print(primer.serialize(format="n3").decode("utf-8")) + print(primer.serialize(format="n3")) # for more insight into things already done, lets see the namespaces -- cgit v1.2.1