davidverweij / csv2docx

Generates .docx files from .csv files using a .docx template with mailmerge fields
MIT License
5 stars 0 forks source link

Add linting and code formatting #10

Closed jawrainey closed 4 years ago

jawrainey commented 4 years ago

@salmannotkhan kindly identified that we had imported and unused the sys library. This could have been automagically fixed prior to committing if we had been using code linting in a more automated workflow, e.g. using flake8 to follow PEP guidelines prior to commits. At the same time, we could also add code formatting with black, and make both runnable via nox, which we use for running tests in #9.

Changes Needed

  1. Add flake8 and a range of sensible plugins, e.g. flake8-import-order, flake8-builtins, flake8-quotes, flake8-docstrings, and flake8-black. This requires adding flake8 as a --dev dependency via poetry.
  2. Add and configure black for code formatting.
  3. Add nox to run flake8 and black as it will be used for running tests.
  4. Add pre-commit as a dev dependency and configure its TOML file accordingly to automate the above prior to a git commit.

See here and here for examples of implementing the above.