[damned-lies/develop] feat: use pre-commit to handle pre commit hooks
- From: Guillaume Bernard <gbernard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies/develop] feat: use pre-commit to handle pre commit hooks
- Date: Mon, 5 Sep 2022 15:42:48 +0000 (UTC)
commit fbe53e0cbf4defd04973d8e6c924aa0f42594d53
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Mon Sep 5 17:34:11 2022 +0200
feat: use pre-commit to handle pre commit hooks
.pre-commit-config.yaml | 16 ++++++++++++++++
CONTRIBUTING.md | 9 +++++++++
requirements-dev.txt | 3 +++
3 files changed, 28 insertions(+)
---
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..4faf6e78
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,16 @@
+repos:
+ - repo: https://github.com/psf/black
+ rev: 22.8.0
+ hooks:
+ - id: black
+ # It is recommended to specify the latest version of Python
+ # supported by your project here, or alternatively use
+ # pre-commit's default_language_version, see
+ # https://pre-commit.com/#top_level-default_language_version
+ language_version: python3.10
+
+ - repo: https://github.com/pycqa/isort
+ rev: 5.10.1
+ hooks:
+ - id: isort
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ca3c4fa1..a3547af4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -219,6 +219,15 @@ Django coding style has precedence over custom rules, which themselves have prec
**Note:** to check the correctness of your code, you can use
[`prospector`](http://prospector.landscape.io/en/master/)
and run it in the project root’s directory. We provide a custom profile called `.prospector.yml`.
+## Use `pre-commit`
+
+We use [`pre-commit`](https://pre-commit.com) in order to manage Git Hooks. Please read the documentation,
but to sum up, you need to install it (see `requirements-dev.txt`) and call it to install `pre-commit` hooks.
It runs [`black`](https://black.readthedocs.io) (a style formatter) and
[`isort`](https://pycqa.github.io/isort) (to sort imports).
+
+```bash
+pip install pre-commit
+pre-commit install
+```
+
## Django Coding Style
`damned-lies` is written following
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 057987ec..17b9975a 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -3,3 +3,6 @@ prospector[with_pyroma,with_bandit]
flake8
coverage
unittest-xml-reporting
+
+black
+isort
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]