Skip to content

Commit cbd6151

Browse files
authored
test: Eliminate flake8 errors in tests (#2353)
Eliminate some occurrences of the following flake8 errors in tests: * E265 block comment should start with '# ' * E266 too many leading '#' for block comment * E402 module level import not at top of file * E712 comparison to False should be 'if cond is False:' or 'if not cond:' * E712 comparison to True should be 'if cond is True:' or 'if cond:' * E722 do not use bare 'except' * F401 ... imported but unused * F403 ... used; unable to detect undefined names * F405 ... may be undefined, or defined from star imports: ... * F541 f-string is missing placeholders * F841 local variable 'result' is assigned to but never used * N806 variable 'TEST_DIR' in function should be lowercase This is pursuant to eliminating [flakeheaven](https://github.com/flakeheaven/flakeheaven), as it no longer supports the latest version of flake8 [[ref](flakeheaven/flakeheaven#132)].
1 parent 4ea1436 commit cbd6151

File tree

19 files changed

+27
-51
lines changed

19 files changed

+27
-51
lines changed

test/jsonld/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
assert plugin
66
assert serializer
77
assert parser
8-
import json
98

109
__all__: List[str] = []

test/jsonld/test_api.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
# -*- coding: UTF-8 -*-
2-
from rdflib.parser import Parser
3-
from rdflib.plugin import register
4-
from rdflib.serializer import Serializer
5-
6-
register("json-ld", Parser, "rdflib.plugins.parsers.jsonld", "JsonLDParser")
7-
register("json-ld", Serializer, "rdflib.plugins.serializers.jsonld", "JsonLDSerializer")
8-
92
from rdflib import Graph, Literal, URIRef
103

114

test/jsonld/test_named_graphs.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# -*- coding: UTF-8 -*-
2-
from rdflib import *
3-
from rdflib.parser import Parser
4-
from rdflib.plugin import register
5-
6-
register("json-ld", Parser, "rdflib.plugins.parsers.jsonld", "JsonLDParser")
7-
register("application/ld+json", Parser, "rdflib.plugins.parsers.jsonld", "JsonLDParser")
2+
from rdflib import ConjunctiveGraph, Dataset, Graph, URIRef
83

94
data = """
105
{

test/test_dataset/test_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_dataset(request):
105105
else:
106106
try:
107107
os.remove(path)
108-
except:
108+
except Exception:
109109
pass
110110

111111

test/test_graph/test_graph_formula.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def checkFormulaStore(store="default", configString=None):
115115
os.unlink(path)
116116
else:
117117
g.store.destroy(configString)
118-
except:
118+
except Exception:
119119
g.close()
120120
if store == "SQLite":
121121
os.unlink(path)

test/test_issues/test_issue492.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# test for https://github.com/RDFLib/rdflib/issues/492
2-
3-
#!/usr/bin/env python3
4-
52
import rdflib
63

74

test/test_issues/test_issue604.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rdflib import *
1+
from rdflib import RDF, BNode, Graph, Literal, Namespace
22
from rdflib.collection import Collection
33

44

test/test_literal/test_term.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def isclose(a, b, rel_tol=1e-09, abs_tol=0.0):
253253
if not case_passed:
254254
try:
255255
case_passed = isclose((case[1] + case[2].value), case[3].value)
256-
except:
256+
except Exception:
257257
pass
258258

259259
if not case_passed:

test/test_misc/test_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ def testEvents(self):
6060
assert c2["bob"] == "uncle"
6161
assert c3["bob"] == "uncle"
6262
del c3["bob"]
63-
assert ("bob" in c1) == False
64-
assert ("bob" in c2) == False
63+
assert ("bob" in c1) is False
64+
assert ("bob" in c2) is False

test/test_namespace/test_namespace.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ def test_expand_curie_exception_messages(self) -> None:
284284
["curie", "expected_result"],
285285
[
286286
("ex:tarek", URIRef("urn:example:tarek")),
287-
("ex:", URIRef(f"urn:example:")),
288-
("ex:a", URIRef(f"urn:example:a")),
289-
("ex:a:b", URIRef(f"urn:example:a:b")),
290-
("ex:a:b:c", URIRef(f"urn:example:a:b:c")),
287+
("ex:", URIRef("urn:example:")),
288+
("ex:a", URIRef("urn:example:a")),
289+
("ex:a:b", URIRef("urn:example:a:b")),
290+
("ex:a:b:c", URIRef("urn:example:a:b:c")),
291291
("ex", ValueError),
292292
("em:tarek", ValueError),
293293
("em:", ValueError),

0 commit comments

Comments
 (0)