Skip to content

Commit

Permalink
lint: specify encoding when using 'open'
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Oct 8, 2021
1 parent 45a7878 commit 13ce559
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tools/docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
Expand Down
2 changes: 1 addition & 1 deletion vunit/sim_if/ghdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
Expand Down
2 changes: 1 addition & 1 deletion vunit/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions vunit/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 13ce559

Please sign in to comment.