Skip to content

Pre commit

Nolwenn edited this page Dec 9, 2022 · 3 revisions

Our pre-commit consist of:

  • Flake8
  • Black
  • Docformatter
  • Pydocstyle
  • MyPy

Flake 8

  • Flake8 will check coding style (PEP8), programming errors, and cyclomatic complexity.
  • Flake8 essentially wraps pep8, pyflakes, and Ned Batchelder's McCabe script.

Black

  • Black is an auto-formatter to ensure that we are consistent with the style guide.
  • It will reformat entire files in place.
  • The main incentive for using Black is to avoid having to think about many configuration options.

Docformatter

  • Docformatter will try to auto format docstrings to follow the IAI-guidelines.
  • It is not very opinionated and should not be a nuance.
  • Most fixes are of the sort of adding . at the end of the docstring heading.

Pydocstyle

  • Pydocstyle is a docstring linter.
  • It enforces much stricter rules then Docformatter, but should still follow the IAI-guidelines with the configuration in the pre-commit.
  • It is much more opinionated then Docformatter and may be a nuance at some times.
    • Specially it does not respect that @properties do not need a docstring. This has been fixed but not been released.

MyPy

  • A python type checker.
  • It will enforce static typing. Removing some of the niceties of Python, but generally it results in more stable code.
  • Of the new additions this is the most frustrating to work with, but the gain is greater than the disadvantage.
Clone this wiki locally