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

[enh] #132: Introduce Black pre-commit

Introduce .pre-commit-config.yml
Document its usage in CONTRIBUTING.md
Add pre-commit dependency as a dev dependency
parent e14417d6
No related branches found
No related tags found
2 merge requests!157v1.0.0rc0: merge dev into master,!135#132: Introduce Black pre-commit
Pipeline #12490 waiting for manual action
repos:
- repo: https://github.com/psf/black
rev: 21.5b0
hooks:
- id: black
# Contribute guide
## Release workflow
## Pre-commit
We are using [`pre-commit`](https://pre-commit.com/) tool to perform checks on staged changes before committing. Such as black formatting.
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
duniterpy> pre-commit install
```
```bash
duniterpy> poetry shell
(duniterpy-UyTOfZjU-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 duniterpy/file.py
```
With `pre-commit`, Black is called on staged files, so the commit should fail in case black would make changes.
You will have to add Black changes in order to commit your changes.
## Release workflow
To handle a release, you have to respect this workflow:
* Verify all features and bug fixes are merged in the `dev` branch.
......
......@@ -73,8 +73,6 @@ poetry run make docs
* When writing docstrings, use the reStructuredText format recommended by https://www.python.org/dev/peps/pep-0287/#docstring-significant-features
* Use `make` commands to check the code and the format.
Black, the formatting tool, requires Python 3.6 or higher.
* Install runtime dependencies
```bash
poetry install --no-dev
......
......@@ -38,5 +38,6 @@ websocket-client = "^0.57"
black = {version = "^21.4b2", allow-prereleases = true}
mypy = "^0.790"
pylint = "^2.7.2"
pre-commit = "^2.12.1"
sphinx = "^3.2.1"
sphinx_rtd_theme = "^0.5.0"
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