riscv / riscv-opcodes

RISC-V Opcodes
https://riscv.org/
BSD 3-Clause "New" or "Revised" License
671 stars 294 forks source link

Improved software engineering quality suggestions #280

Open Timmmm opened 2 weeks ago

Timmmm commented 2 weeks ago

Hi, I was wondering if you would be open to PRs to improve the general software engineering quality of this repo. This is the sort of thing I'm thinking of in increasing order of invasiveness:

  1. Add pre-commit, tell it to format all the Python code using Black or Ruff and enforce in CI.
  2. Add Pylint to pre-commit.
  3. Restructure the code to turn it into an actual Python package with pyproject.toml etc. Publish it on Pypi.
  4. Add static type hints.
  5. Add Pyright (static type checker) to pre-commit to enforce them.

There's also some low hanging fruit in the actual code:

  1. Use argparse (Typer is a better option but it's beneficial not to add a third party dependency.)
  2. Switch from ad-hoc dictionaries to dataclasses.
  3. Don't reparse the files 3 times.

I can do all that fairly easily but I thought I'd check if you would actually accept those improvements first. Seems like you might a bit review bottlenecked based on the open PRs (who isn't?).

aswaterman commented 1 week ago

@neelgala is the author of the bulk of the Python code, so I'll defer to him. But at first blush this seems reasonable.