Skip to content
Snippets Groups Projects
Commit d8ff1c71 authored by Moul's avatar Moul
Browse files

[doc] #162, #165: Change pre-commit hooks documentation

Update hooks in used
Install pre-commit via 'apt' or pip
Recommended way to install it outside of poetry virtualenv
Document how to 'run' tools installed into pre-commit virtualenv
parent caf2dbe7
Branches
No related tags found
No related merge requests found
# Contribute guide # Contribute guide
## Pre-commit ## Pre-commit
We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing. Such as black formatting. We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing.
Depending whether you prefer to work ouside or inside Poetry virtual environment, you should stick to one usage or use both to still have this usefull checks. We are using it for `black` formatting, `isort` imports sorting, `pylint` code linting, `mypy` typing, and `gitlab-ci` linting.
`pre-commit` can be used from the installation on your system or from inside Poetry virtual environment where it is installed.
Install `pre-commit` from your distribution. In case it is an outdated version, install it from `pip`:
```bash
sudo apt install pre-commit
pip install --user pre-commit
```
To install the `git-hooks`, run: To install the `git-hooks`, run:
```bash ```bash
pip3 install --user pre-commit
duniterpy> pre-commit install duniterpy> pre-commit install
``` ```
Then each time you commit changes, the hooks will perform checks.
To manually run one of the tool above, run (eg for `isort`):
```bash ```bash
duniterpy> poetry shell duniterpy> pre-commit run isort --all-files
(duniterpy-UyTOfZjU-py3.9) pre-commit install
``` ```
### Black formatting ### Black formatting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment