Enable Pylint in CI and fix its errors (#311)

* Remove wildcard imports

Use explicit imports rather than wildcards. This is more maintainable.

* Enable Pylint in CI and fix its errors

The main fixes were:

* Specify encoding for all file opens. By default it depends on environment variables which is bad.
* Use `with` to open files. Otherwise they don't necessarily get closed.

There were also a few minor things like using `enumerate`, not using objects as default arguments, etc. In some cases I slightly refactored the code.
This commit is contained in:
Tim Hutt
2024-11-05 14:32:12 +00:00
committed by GitHub
parent 6bb00f9056
commit 359a94356d
13 changed files with 225 additions and 163 deletions

View File

@@ -1,7 +1,9 @@
import logging
import pprint
from pathlib import Path
from shared_utils import *
from constants import csrs, csrs32
from shared_utils import InstrDict
pp = pprint.PrettyPrinter(indent=2)
logging.basicConfig(level=logging.INFO, format="%(levelname)s:: %(message)s")
@@ -17,13 +19,12 @@ def make_sverilog(instr_dict: InstrDict):
f" localparam logic [11:0] CSR_{name.upper()} = 12'h{hex(num)[2:]};\n"
)
sverilog_file = open("inst.sverilog", "w")
sverilog_file.write(
Path("inst.sverilog").write_text(
f"""
/* Automatically generated by parse_opcodes */
package riscv_instr;
{names_str}
endpackage
"""
""",
encoding="utf-8",
)
sverilog_file.close()