Skip to content

Commit ab3df6b

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

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

implementations/c-jsu/bowtie_jsu_compile.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@
4848
# environment variables
4949
ENV: Path = Path(__file__).parent / ".env"
5050

51+
5152
def get_version(cmd: list[str]) -> str:
5253
"""Run external command and return first non empty output line."""
5354
ps = subprocess.run(cmd, text=True, capture_output=True, check=True) # noqa: S603
5455
lines = list(filter(lambda s: s != "", ps.stdout.split("\n")))
5556
return lines[0]
5657

58+
5759
def json_file(filename: str, data: Json) -> Path:
5860
"""Put JSON data into a temporary file."""
5961
file: Path = TMP / filename
@@ -67,7 +69,6 @@ class RunnerError(Exception):
6769

6870

6971
class Runner:
70-
7172
def __init__(self, language: str = "python", options: list[str] = []):
7273

7374
# setup environment
@@ -131,13 +132,14 @@ def __init__(self, language: str = "python", options: list[str] = []):
131132
# compiler call prefix missing version, output file and input schema
132133
self.jsu_compile = [
133134
"jsu-compile",
134-
"--cache", str(CACHE),
135-
"--no-fix", # do not try to fix the schema
136-
"--no-strict", # accept any odd looking schema
137-
"--no-reporting", # do not generate location reporting code
138-
"--loose", # ints are floats, floats may be ints
139-
# next options may override the above defaults
140-
*options,
135+
"--cache",
136+
str(CACHE),
137+
"--no-fix", # do not try to fix the schema
138+
"--no-strict", # accept any odd looking schema
139+
"--no-reporting", # do not generate location reporting code
140+
"--loose", # ints are floats, floats may be ints
141+
# next options may override the above defaults
142+
*options,
141143
]
142144
self.jsu_version = get_version(["jsu-compile", "--version"])
143145

@@ -151,9 +153,11 @@ def compile_schema(self, schema: JsonObject) -> Path:
151153

152154
jsu_compile = [
153155
*self.jsu_compile,
154-
"--schema-version", str(self.version or 7),
155-
"-o", str(output_file),
156-
str(schema_file),
156+
"--schema-version",
157+
str(self.version or 7),
158+
"-o",
159+
str(output_file),
160+
str(schema_file),
157161
]
158162

159163
subprocess.run(jsu_compile, text=True, check=True) # noqa: S603
@@ -166,8 +170,10 @@ def run_test(self, test: Json) -> bool:
166170
test_file = json_file("test.json", test)
167171

168172
ps = subprocess.run( # noqa: S603
169-
[ *self.runner, str(test_file) ],
170-
text=True, capture_output=True, check=True,
173+
[*self.runner, str(test_file)],
174+
text=True,
175+
capture_output=True,
176+
check=True,
171177
)
172178

173179
if "FAIL" in ps.stdout:
@@ -244,8 +250,7 @@ def cmd_run(self, req: JsonObject) -> JsonObject:
244250

245251
# apply to test vector
246252
results = [
247-
{"valid": self.run_test(test["instance"])}
248-
for test in tests
253+
{"valid": self.run_test(test["instance"])} for test in tests
249254
]
250255

251256
except Exception: # an internal error occurred

0 commit comments

Comments
 (0)