From 4eac0983022405f7c06bf644d34b4891e12488e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9ry=20Febvre?= Date: Tue, 20 Dec 2022 14:52:54 +0100 Subject: [PATCH] Add pre-commit hooks --- .pre-commit-config.yaml | 30 ++++++++++++++++++++++++++++++ CONTRIBUTING.md | 6 ++++++ requirements-dev.txt | 5 +++++ 3 files changed, 41 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 requirements-dev.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..ae1e12eb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # Identify invalid files + - id: check-ast + - id: check-json + - id: check-yaml + + # git checks + - id: check-merge-conflict + - id: check-added-large-files + - id: check-case-conflict + + # Python checks + - id: check-docstring-first + - id: requirements-txt-fixer + - id: fix-byte-order-marker + + # General quality checks + - id: mixed-line-ending + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: check-executables-have-shebangs + - id: end-of-file-fixer + +- repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f1f34c3..7fb06dca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,10 +75,16 @@ Komikku can be built in a Python virtual environment. However, some tools and de ```sh # Create venv python3 -m venv .venv + # Activate venv source .venv/bin/activate + # Install dependencies pip install -r requirements.txt + pip install -r requirements-dev.txt + + # Install pre-commit hooks + pre-commit install ``` NOTE: Python package `file-magic` is an possible alternative to `python-magic`. diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..3e227f6e --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +flake8 +pre-commit +pycodestyle +pytest +pytest-steps