Skip to content

Commit fda52f0

Browse files
committed
Fixed linting
1 parent 73f3764 commit fda52f0

9 files changed

Lines changed: 94 additions & 81 deletions

File tree

examples/vhdl/embedded_python/run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def hello_world():
1313
print("Hello World")
1414

1515

16-
class Plot():
16+
class Plot:
1717

1818
def __init__(self, x_points, y_limits, title, x_label, y_label):
1919
from matplotlib import pyplot as plt
@@ -30,7 +30,7 @@ def __init__(self, x_points, y_limits, title, x_label, y_label):
3030
plt.ylim(*y_limits)
3131
x_vector = [x_points[0]] * len(x_points)
3232
y_vector = [(y_limits[0] + y_limits[1]) / 2] * len(x_points)
33-
line, = plt.plot(x_vector, y_vector, 'r-')
33+
(line,) = plt.plot(x_vector, y_vector, "r-")
3434
fig.canvas.draw()
3535
fig.canvas.flush_events()
3636
plt.show(block=False)
@@ -78,8 +78,8 @@ def main():
7878
lib = vu.add_library("lib")
7979
lib.add_source_files(root / "*.vhd")
8080

81-
vu.set_compile_option("rivierapro.vcom_flags" , ["-dbg"])
82-
vu.set_sim_option("rivierapro.vsim_flags" , ["-interceptcoutput"])
81+
vu.set_compile_option("rivierapro.vcom_flags", ["-dbg"])
82+
vu.set_sim_option("rivierapro.vsim_flags", ["-interceptcoutput"])
8383
# Crashes RPRO for some reason. TODO: Fix when the C code is properly
8484
# integrated into the project. Must be able to debug the C code.
8585
# vu.set_sim_option("rivierapro.vsim_flags" , ["-cdebug"])
@@ -88,4 +88,4 @@ def main():
8888

8989

9090
if __name__ == "__main__":
91-
main()
91+
main()

vunit/builtins.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ def _add_data_types(self, external=None):
8989

9090
for key in ["string", "integer_vector"]:
9191
self._add_files(
92-
pattern=str(VHDL_PATH / "data_types" / "src" / "api" / f"external_{key!s}_pkg.vhd")
93-
if external is None or key not in external or not external[key] or external[key] is True
94-
else external[key],
92+
pattern=(
93+
str(VHDL_PATH / "data_types" / "src" / "api" / f"external_{key!s}_pkg.vhd")
94+
if external is None or key not in external or not external[key] or external[key] is True
95+
else external[key]
96+
),
9597
allow_empty=False,
9698
)
9799

@@ -213,7 +215,6 @@ def _add_python(self):
213215
if not self._vhdl_standard >= VHDL.STD_2008:
214216
raise RuntimeError("Python package only supports vhdl 2008 and later")
215217

216-
# TODO: Create enums for FLIs
217218
python_package_supported_flis = set(["VHPI", "FLI"])
218219
simulator_supported_flis = self._simulator_class.supported_foreign_language_interfaces()
219220
if not python_package_supported_flis & simulator_supported_flis:

vunit/python_pkg.py

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44
#
55
# Copyright (c) 2014-2023, Lars Asplund lars.anders.asplund@gmail.com
66

7+
"""
8+
Temporary helper module to compile C-code used by python_pkg.
9+
"""
710
from pathlib import Path
811
from glob import glob
912
import subprocess
1013
import sys
1114

1215

1316
def compile_vhpi_application(run_script_root, vu):
17+
"""
18+
Compile VHPI application used by Aldec's simulators.
19+
"""
1420
path_to_shared_lib = (run_script_root / "vunit_out" / vu.get_simulator_name() / "libraries").resolve()
1521
if not path_to_shared_lib.exists():
1622
path_to_shared_lib.mkdir(parents=True, exist_ok=True)
@@ -20,31 +26,34 @@ def compile_vhpi_application(run_script_root, vu):
2026
python_shared_lib = f"python{sys.version_info[0]}{sys.version_info[1]}"
2127
path_to_python_pkg = Path(__file__).parent.resolve() / "vhdl" / "python" / "src"
2228
c_file_paths = [path_to_python_pkg / "python_pkg_vhpi.c", path_to_python_pkg / "python_pkg.c"]
23-
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve()
29+
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() # pylint: disable=protected-access
2430
ccomp_executable = path_to_simulator / "ccomp.exe"
2531

26-
proc = subprocess.run([
27-
str(ccomp_executable),
28-
"-vhpi",
29-
"-dbg",
30-
"-verbose",
31-
"-o",
32-
'"' + str(shared_lib) + '"',
33-
"-l",
34-
python_shared_lib,
35-
"-l",
36-
"python3",
37-
"-l",
38-
"_tkinter",
39-
"-I",
40-
'"' + str(path_to_python_include) + '"',
41-
"-I",
42-
'"' + str(path_to_python_pkg) + '"',
43-
"-L",
44-
'"' + str(path_to_python_libs) + '"',
45-
" ".join(['"' + str(path) + '"' for path in c_file_paths])],
32+
proc = subprocess.run(
33+
[
34+
str(ccomp_executable),
35+
"-vhpi",
36+
"-dbg",
37+
"-verbose",
38+
"-o",
39+
'"' + str(shared_lib) + '"',
40+
"-l",
41+
python_shared_lib,
42+
"-l",
43+
"python3",
44+
"-l",
45+
"_tkinter",
46+
"-I",
47+
'"' + str(path_to_python_include) + '"',
48+
"-I",
49+
'"' + str(path_to_python_pkg) + '"',
50+
"-L",
51+
'"' + str(path_to_python_libs) + '"',
52+
" ".join(['"' + str(path) + '"' for path in c_file_paths]),
53+
],
4654
capture_output=True,
4755
text=True,
56+
check=False,
4857
)
4958

5059
if proc.returncode != 0:
@@ -53,8 +62,11 @@ def compile_vhpi_application(run_script_root, vu):
5362
raise RuntimeError("Failed to compile VHPI application")
5463

5564

56-
def compile_fli_application(run_script_root, vu):
57-
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve()
65+
def compile_fli_application(run_script_root, vu): # pylint: disable=too-many-locals
66+
"""
67+
Compile FLI application used by Questa.
68+
"""
69+
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() # pylint: disable=protected-access
5870
path_to_simulator_include = (path_to_simulator / ".." / "include").resolve()
5971

6072
# 32 or 64 bit installation?
@@ -63,6 +75,7 @@ def compile_fli_application(run_script_root, vu):
6375
[vsim_executable, "-version"],
6476
capture_output=True,
6577
text=True,
78+
check=False,
6679
)
6780
if proc.returncode != 0:
6881
print(proc.stderr)
@@ -94,16 +107,17 @@ def compile_fli_application(run_script_root, vu):
94107
args += ["-ansi", "-pedantic"]
95108

96109
args += [
97-
'-I' + str(path_to_simulator_include),
98-
'-I' + str(path_to_python_include),
110+
"-I" + str(path_to_simulator_include),
111+
"-I" + str(path_to_python_include),
99112
"-freg-struct-return",
100-
str(c_file_path)
113+
str(c_file_path),
101114
]
102115

103116
proc = subprocess.run(
104117
args,
105118
capture_output=True,
106119
text=True,
120+
check=False,
107121
)
108122
if proc.returncode != 0:
109123
print(proc.stdout)
@@ -139,6 +153,7 @@ def compile_fli_application(run_script_root, vu):
139153
args,
140154
capture_output=True,
141155
text=True,
156+
check=False,
142157
)
143158
if proc.returncode != 0:
144159
print(proc.stdout)

vunit/sim_if/activehdl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ def compile_vhdl_file_command(self, source_file):
136136
str(Path(self._library_cfg).parent),
137137
]
138138
+ source_file.compile_options.get("activehdl.vcom_flags", [])
139-
+
140-
[
139+
+ [
141140
self._std_str(source_file.get_vhdl_standard()),
142141
"-work",
143142
source_file.library.name,

vunit/test/runner.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestRunner(object): # pylint: disable=too-many-instance-attributes
3333
VERBOSITY_NORMAL = 1
3434
VERBOSITY_VERBOSE = 2
3535

36-
def __init__(# pylint: disable=too-many-arguments
36+
def __init__( # pylint: disable=too-many-arguments
3737
self,
3838
report,
3939
output_path,
@@ -200,7 +200,7 @@ def _add_skipped_tests(self, test_suite, results, start_time, num_tests, output_
200200
results[name] = SKIPPED
201201
self._add_results(test_suite, results, start_time, num_tests, output_file_name)
202202

203-
def _run_test_suite(# pylint: disable=too-many-locals
203+
def _run_test_suite( # pylint: disable=too-many-locals
204204
self, test_suite, write_stdout, num_tests, output_path, output_file_name
205205
):
206206
"""
@@ -226,7 +226,7 @@ def _run_test_suite(# pylint: disable=too-many-locals
226226
if write_stdout:
227227
output_from = self._stdout_ansi
228228
else:
229-
color_output_file = Path(color_output_file_name).open(# pylint: disable=consider-using-with
229+
color_output_file = Path(color_output_file_name).open( # pylint: disable=consider-using-with
230230
"w", encoding="utf-8"
231231
)
232232
output_from = color_output_file
@@ -244,9 +244,7 @@ def read_output():
244244
return contents
245245

246246
results = test_suite.run(
247-
output_path=output_path,
248-
read_output=read_output,
249-
run_script_path=self._run_script_path
247+
output_path=output_path, read_output=read_output, run_script_path=self._run_script_path
250248
)
251249
except KeyboardInterrupt as exk:
252250
self._add_skipped_tests(test_suite, results, start_time, num_tests, output_file_name)
@@ -302,7 +300,7 @@ def _create_test_mapping_file(self, test_suites):
302300
mapping.add(f"{Path(test_output).name!s} {test_suite.name!s}")
303301

304302
# Sort by everything except hash
305-
mapping = sorted(mapping, key=lambda value: value[value.index(" "):])
303+
mapping = sorted(mapping, key=lambda value: value[value.index(" ") :])
306304

307305
with mapping_file_name.open("w", encoding="utf-8") as fptr:
308306
for value in mapping:
@@ -457,7 +455,7 @@ def wrap(file_obj, use_color=True):
457455
NOTE:
458456
imports colorama here to avoid dependency from setup.py importing VUnit before colorama is installed
459457
"""
460-
from colorama import (# type: ignore # pylint: disable=import-outside-toplevel
458+
from colorama import ( # type: ignore # pylint: disable=import-outside-toplevel
461459
AnsiToWin32,
462460
)
463461

vunit/test/suites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _read_test_results(self, file_name): # pylint: disable=too-many-branches
260260

261261
for line in test_results.splitlines():
262262
if line.startswith("test_start:"):
263-
test_name = line[len("test_start:"):]
263+
test_name = line[len("test_start:") :]
264264
if test_name not in test_starts:
265265
test_starts.append(test_name)
266266

0 commit comments

Comments
 (0)