Skip to content
Snippets Groups Projects
Commit 6629e21d authored by Eduardo Rodrigues's avatar Eduardo Rodrigues Committed by Patrick Koppenburg
Browse files

Add documentation on style, type hints and pre-commit hooks

parent fe6bad57
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!925Add documentation on style, type hints and pre-commit hooks
......@@ -22,8 +22,31 @@ Alternatively, especially for small changes, a development environment can be bu
git lb-use DaVinci
Coding conventions
------------------
Coding conventions, style and type hints
----------------------------------------
Python code in the stack follows the `PEP8 guidelines <https://peps.python.org/pep-0008/>`_
and other general good practices:
* Include comments and documentation ("docstrings") when the intent of a line, function, class, or module is not obvious.
* Factor code into functions when there is repetition and/or for clarity.
* When modifying an existing file, following the conventions of the surrounding code.
Style and formatting checks are implemented in continuous integration (see subsection below)
via `pre-commit <https://pre-commit.com/>`_ hooks.
The following hooks are implemented: `Black`, `codespell`, `Flake8`, `pre-commit-hooks`, `pyupgrade`.
Refer to the repository `.pre-commit-config.yaml` for the actual implementation details.
Developers are encouraged to run the hooks locally prior to pushing to the repositories.
This is easily done with the following:
.. code-block:: bash
pre-commit install # only needed once to install pre-commit
pre-commit run --all-files # example to run all hooks on all files
Static typing (hints) is available in Python 3 and the offline stack now implements type hints and checking thereof.
Type hints are for now not compulsory but are strongly encouraged.
Tests and continuous integration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment