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

[doc] contributing: Update pre-commit/Formatting sections

To introduce pre-commit generalization usage in #400
parent 457c1ff4
No related branches found
No related tags found
No related merge requests found
...@@ -44,18 +44,29 @@ Please read their documentations on how to use them the best possible. ...@@ -44,18 +44,29 @@ Please read their documentations on how to use them the best possible.
- [Pendulum](https://pendulum.eustace.io/docs/) - [Pendulum](https://pendulum.eustace.io/docs/)
- [texttable](https://github.com/foutaise/texttable/#documentation) - [texttable](https://github.com/foutaise/texttable/#documentation)
## Formatting ## Pre-commit
We are using [Black](https://github.com/python/black) formatter tool. We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing. Such as black formatting.
To have Black installed in your Poetry virtualenv, you will need Python v3.6 or greater. 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.
`pre-commit` can be used from the installation on your system or from inside Poetry virtual environment where it is installed.
To install the `git-hooks`, run:
```bash
pip3 install --user pre-commit
silkaj> pre-commit install
```
```bash
silkaj> poetry shell
(silkaj-58dUTebQ-py3.9) pre-commit install
```
### Black formatting
We are using [Black](https://github.com/psf/black) formatter tool.
Run Black on a Python file to format it: Run Black on a Python file to format it:
```bash ```bash
poetry run black silkaj/cli.py poetry run black silkaj/cli.py
``` ```
With `pre-commit`, Black is called on staged files, so the commit should fail in case black would make changes.
### Pre-commit
Then, you can use the `pre-commit` tool to check staged changes before committing.
To do so, you need to run `pre-commit install` to install the git hook.
Black is called on staged files, so commit should fail in case black made changes.
You will have to add Black changes in order to commit your changes. You will have to add Black changes in order to commit your changes.
## Tests ## Tests
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment