Vela's Python codebase is PEP8 compliant with the exception of a 120 character line length. The following code formatting and linting tools are run on all the Python files (excluding the directories ethosu/vela/tflite/
and ethosu/vela/ethos_u55_regs
because they contain auto-generated code):
These tools are run using the pre-commit framework. This is also used to run the following test and coverage tools:
To install pre-commit, pytest and pytest-cov use the following command:
pip install pre-commit ... pip install pytest ... pip install pytest-cov
The remaining tools will all be installed automatically upon first use.
To support code development all the above tools can be configured to run automatically on git commit
(except pytest-cov which is run on git push
) by using the command:
$ pre-commit install pre-commit installed at .git/hooks/pre-commit
When committing (or pushing) if any of the tools result in a failure (meaning an issue was found) then it will need to be resolved and the git operation repeated.
All of the tools can be run individually by invoking them using the following pre-commit framework commands:
$ pre-commit run mypy --all-files ... $ pre-commit run reorder-python-imports --all-files ... $ pre-commit run black --all-files ... $ pre-commit run flake8 --all-files ... $ pre-commit run pylint --all-files ... $ pre-commit run pytest ... $ pre-commit run pytest-cov --hook-stage push ...
Alternatively, all of the commit stage hooks can be run using the command:
$ pre-commit run --all-files mypy.....................................................................Passed Reorder python imports...................................................Passed black....................................................................Passed flake8...................................................................Passed pylint...................................................................Passed pytest...................................................................Passed