From 45a78783ec5aa9fc2c8c91e2c57de0f92bd002bc Mon Sep 17 00:00:00 2001 From: umarcor Date: Fri, 8 Oct 2021 15:19:53 +0200 Subject: [PATCH 1/2] vunit/parsing/tokenizer: fix typing --- vunit/parsing/tokenizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vunit/parsing/tokenizer.py b/vunit/parsing/tokenizer.py index e6e79c25f..7308f52fc 100644 --- a/vunit/parsing/tokenizer.py +++ b/vunit/parsing/tokenizer.py @@ -13,7 +13,7 @@ from vunit.ostools import read_file, file_exists, simplify_path -TokenType = collections.namedtuple("Token", ["kind", "value", "location"]) +TokenType = collections.namedtuple("TokenType", ["kind", "value", "location"]) def Token(kind, value="", location=None): # pylint: disable=invalid-name From 13ce55969605546bab2acedf124c55a06189c864 Mon Sep 17 00:00:00 2001 From: umarcor Date: Tue, 28 Sep 2021 12:58:34 +0200 Subject: [PATCH 2/2] lint: specify encoding when using 'open' --- tools/docs_utils.py | 2 +- vunit/sim_if/ghdl.py | 2 +- vunit/test/runner.py | 2 +- vunit/ui/__init__.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/docs_utils.py b/tools/docs_utils.py index 7b5bf2d90..e1e5d38d5 100644 --- a/tools/docs_utils.py +++ b/tools/docs_utils.py @@ -24,7 +24,7 @@ def examples(): Traverses the examples directory and generates examples.rst with the docstrings """ eg_path = ROOT.parent / "examples" - egs_fptr = (ROOT / "examples.rst").open("w+") + egs_fptr = (ROOT / "examples.rst").open("w+", encoding="utf-8") egs_fptr.write("\n".join([".. _examples:\n", "Examples", "========", "\n"])) for language, subdir in {"VHDL": "vhdl", "SystemVerilog": "verilog"}.items(): egs_fptr.write("\n".join([language, "~~~~~~~~~~~~~~~~~~~~~~~", "\n"])) diff --git a/vunit/sim_if/ghdl.py b/vunit/sim_if/ghdl.py index 7c6e87243..736e0cafc 100644 --- a/vunit/sim_if/ghdl.py +++ b/vunit/sim_if/ghdl.py @@ -309,7 +309,7 @@ def _get_command(self, config, output_path, elaborate_only, ghdl_e, wave_file): makedirs(output_path, mode=0o777) except OSError: pass - with (Path(output_path) / "args.json").open("w") as fname: + with (Path(output_path) / "args.json").open("w", encoding="utf-8") as fname: dump( { "bin": str(Path(output_path) / f"{config.entity_name!s}-{config.architecture_name!s}"), diff --git a/vunit/test/runner.py b/vunit/test/runner.py index 03fe4f02b..a4b118656 100644 --- a/vunit/test/runner.py +++ b/vunit/test/runner.py @@ -307,7 +307,7 @@ def _print_output(self, output_file_name): """ Print contents of output file if it exists """ - with Path(output_file_name).open("r") as fread: + with Path(output_file_name).open("r", encoding="utf-8") as fread: for line in fread.readlines(): self._stdout_ansi.write(line) diff --git a/vunit/ui/__init__.py b/vunit/ui/__init__.py index 710044af9..80ed8e1be 100644 --- a/vunit/ui/__init__.py +++ b/vunit/ui/__init__.py @@ -248,7 +248,7 @@ def add_source_files_from_csv(self, project_csv_path: Union[str, Path], vhdl_sta ppath = Path(project_csv_path) - with ppath.open() as csv_path_file: + with ppath.open("r", encoding="utf-8") as csv_path_file: for row in csv.reader(csv_path_file): if len(row) == 2: lib_name = row[0].strip() @@ -828,7 +828,7 @@ def _main_export_json(self, json_file_name: Union[str, Path]): # pylint: disabl tests=tests, ) - with Path(json_file_name).open("w") as fptr: + with Path(json_file_name).open("w", encoding="utf-8") as fptr: json.dump(json_data, fptr, sort_keys=True, indent=4, separators=(",", ": ")) return True