Skip to content

Commit 757df7b

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

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
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
@@ -126,13 +127,14 @@ def __init__(self, language: str = "python", options: list[str] = []):
126127
# compiler call prefix missing version, output file and input schema
127128
self.jsu_compile = [
128129
"jsu-compile",
129-
"--cache", str(CACHE),
130-
"--no-fix", # do not try to fix the schema
131-
"--no-strict", # accept any odd looking schema
132-
"--no-reporting", # do not generate location reporting code
133-
"--loose", # ints are floats, floats may be ints
134-
# next options may override the above defaults
135-
*options,
130+
"--cache",
131+
str(CACHE),
132+
"--no-fix", # do not try to fix the schema
133+
"--no-strict", # accept any odd looking schema
134+
"--no-reporting", # do not generate location reporting code
135+
"--loose", # ints are floats, floats may be ints
136+
# next options may override the above defaults
137+
*options,
136138
]
137139
self.jsu_version = get_version(["jsu-compile", "--version"])
138140

@@ -146,9 +148,11 @@ def compile_schema(self, schema: JsonObject) -> Path:
146148

147149
jsu_compile = [
148150
*self.jsu_compile,
149-
"--schema-version", str(self.version or 7),
150-
"-o", str(output_file),
151-
str(schema_file),
151+
"--schema-version",
152+
str(self.version or 7),
153+
"-o",
154+
str(output_file),
155+
str(schema_file),
152156
]
153157

154158
subprocess.run(jsu_compile, text=True, check=True) # noqa: S603
@@ -161,8 +165,10 @@ def run_test(self, test: Json) -> bool:
161165
test_file = json_file("test.json", test)
162166

163167
ps = subprocess.run( # noqa: S603
164-
[ *self.runner, str(test_file) ],
165-
text=True, capture_output=True, check=True,
168+
[*self.runner, str(test_file)],
169+
text=True,
170+
capture_output=True,
171+
check=True,
166172
)
167173

168174
if "FAIL" in ps.stdout:
@@ -236,8 +242,7 @@ def cmd_run(self, req: JsonObject) -> JsonObject:
236242

237243
# apply to test vector
238244
results = [
239-
{"valid": self.run_test(test["instance"])}
240-
for test in tests
245+
{"valid": self.run_test(test["instance"])} for test in tests
241246
]
242247

243248
except Exception: # an internal error occurred

implementations/python-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
@@ -126,13 +127,14 @@ def __init__(self, language: str = "python", options: list[str] = []):
126127
# compiler call prefix missing version, output file and input schema
127128
self.jsu_compile = [
128129
"jsu-compile",
129-
"--cache", str(CACHE),
130-
"--no-fix", # do not try to fix the schema
131-
"--no-strict", # accept any odd looking schema
132-
"--no-reporting", # do not generate location reporting code
133-
"--loose", # ints are floats, floats may be ints
134-
# next options may override the above defaults
135-
*options,
130+
"--cache",
131+
str(CACHE),
132+
"--no-fix", # do not try to fix the schema
133+
"--no-strict", # accept any odd looking schema
134+
"--no-reporting", # do not generate location reporting code
135+
"--loose", # ints are floats, floats may be ints
136+
# next options may override the above defaults
137+
*options,
136138
]
137139
self.jsu_version = get_version(["jsu-compile", "--version"])
138140

@@ -146,9 +148,11 @@ def compile_schema(self, schema: JsonObject) -> Path:
146148

147149
jsu_compile = [
148150
*self.jsu_compile,
149-
"--schema-version", str(self.version or 7),
150-
"-o", str(output_file),
151-
str(schema_file),
151+
"--schema-version",
152+
str(self.version or 7),
153+
"-o",
154+
str(output_file),
155+
str(schema_file),
152156
]
153157

154158
subprocess.run(jsu_compile, text=True, check=True) # noqa: S603
@@ -161,8 +165,10 @@ def run_test(self, test: Json) -> bool:
161165
test_file = json_file("test.json", test)
162166

163167
ps = subprocess.run( # noqa: S603
164-
[ *self.runner, str(test_file) ],
165-
text=True, capture_output=True, check=True,
168+
[*self.runner, str(test_file)],
169+
text=True,
170+
capture_output=True,
171+
check=True,
166172
)
167173

168174
if "FAIL" in ps.stdout:
@@ -236,8 +242,7 @@ def cmd_run(self, req: JsonObject) -> JsonObject:
236242

237243
# apply to test vector
238244
results = [
239-
{"valid": self.run_test(test["instance"])}
240-
for test in tests
245+
{"valid": self.run_test(test["instance"])} for test in tests
241246
]
242247

243248
except Exception: # an internal error occurred

0 commit comments

Comments
 (0)