Skip to content

Commit af7b89d

Browse files
committed
ui: add type annotations
1 parent 1af5128 commit af7b89d

3 files changed

Lines changed: 92 additions & 56 deletions

File tree

vunit/project.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010
Functionality to represent and operate on a HDL code project
1111
"""
12-
from typing import Optional
12+
from typing import Optional, Union
1313
from pathlib import Path
1414
import logging
1515
from collections import OrderedDict
@@ -83,7 +83,7 @@ def add_builtin_library(self, logical_name):
8383
def add_library(
8484
self,
8585
logical_name,
86-
directory,
86+
directory: Union[str, Path],
8787
vhdl_standard: VHDLStandard = VHDL.STD_2008,
8888
is_external=False,
8989
):
@@ -93,19 +93,18 @@ def add_library(
9393
"""
9494
self._validate_new_library_name(logical_name)
9595

96+
dpath = Path(directory)
97+
dstr = str(directory)
98+
9699
if is_external:
97-
if not exists(directory):
98-
raise ValueError("External library %r does not exist" % directory)
100+
if not dpath.exists():
101+
raise ValueError("External library %r does not exist" % dstr)
99102

100-
if not isdir(directory):
101-
raise ValueError(
102-
"External library must be a directory. Got %r" % directory
103-
)
103+
if not dpath.is_dir():
104+
raise ValueError("External library must be a directory. Got %r" % dstr)
104105

105-
library = Library(
106-
logical_name, directory, vhdl_standard, is_external=is_external
107-
)
108-
LOGGER.debug("Adding library %s with path %s", logical_name, directory)
106+
library = Library(logical_name, dstr, vhdl_standard, is_external=is_external)
107+
LOGGER.debug("Adding library %s with path %s", logical_name, dstr)
109108

110109
self._libraries[logical_name] = library
111110
self._lower_library_names_dict[logical_name.lower()] = library.name

vunit/sim_if/ghdl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def _get_command(self, config, output_path, elaborate_only, ghdl_e, wave_file):
303303
cmd += ["--no-run"]
304304
else:
305305
try:
306-
os.makedirs(output_path, mode=0o777)
306+
makedirs(output_path, mode=0o777)
307307
except OSError:
308308
pass
309309
with (Path(output_path) / "args.json").open("w") as fname:
@@ -337,7 +337,7 @@ def simulate( # pylint: disable=too-many-locals
337337

338338
if self._gtkwave_fmt is not None:
339339
data_file_name = str(Path(script_path) / ("wave.%s" % self._gtkwave_fmt))
340-
if Path(data_file_name).exists():
340+
if Path(data_file_name).exists():
341341
remove(data_file_name)
342342
else:
343343
data_file_name = None

0 commit comments

Comments
 (0)