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

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

To introduce pre-commit generalization usage in #400/#401
parent 8bf7ff86
No related branches found
No related tags found
1 merge request!180README and CONTRIBUTING enhancements
......@@ -44,19 +44,31 @@ Please read their documentations on how to use them the best possible.
- [Pendulum](https://pendulum.eustace.io/docs/)
- [texttable](https://github.com/foutaise/texttable/#documentation)
## Formatting
We are using [Black](https://github.com/python/black) formatter tool.
To have Black installed in your Poetry virtualenv, you will need Python v3.6 or greater.
## Pre-commit
We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing.
We are using it for `black` formatting, `isort` imports sorting, and `gitlab-ci` linting. We will use it for `pylint` code linting, `mypy` typing in the future.
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
sudo apt install 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:
```bash
poetry run black silkaj/cli.py
```
### 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.
With `pre-commit`, Black is called on staged files, so the commit should fail in case black would make changes.
You will have to `git add` Black changes in order to commit your changes.
## Tests
We are using [Pytest](https://pytest.org) as a tests framework. To know more about how Silkaj implement it read the [project test documentation](doc/test_and_coverage.md).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment