From b3548b4632c1334730b344a985911cf8f7675ea7 Mon Sep 17 00:00:00 2001 From: westfarn Date: Sun, 6 Jul 2025 17:41:46 +0000 Subject: [PATCH] Add .pre-commit-config.yaml --- .pre-commit-config.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8e7ba60 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +# .pre-commit-config.yaml +repos: + # Black (code formatter) + - repo: https://github.com/psf/black + rev: 24.4.2 # Use the latest stable version + hooks: + - id: black + language_version: python3.11 # Specify your Python version + + # Flake8 (linter) + - repo: https://github.com/PyCQA/flake8 + rev: 7.1.0 # Use the latest stable version + hooks: + - id: flake8 + additional_dependencies: [ + "flake8-bugbear", # Optional: for common programming mistakes + "flake8-comprehensions", # Optional: for better comprehensions + "flake8-isort", # Optional: to integrate isort checks with flake8 + "pep8-naming", # Optional: for PEP8 naming conventions + ] + + # isort (import sorter) + - repo: https://https://github.com/PyCQA/isort + rev: 5.13.2 # Use the latest stable version + hooks: + - id: isort + name: isort (python) + args: ["--profile", "black"] # Use black profile for compatibility + + # Custom Hook for Django Tests with Coverage + - repo: local + hooks: + - id: django-test-coverage + name: Django Test Coverage Check + entry: bash -c 'coverage run manage.py test --failfast && coverage report --fail-under=90' # Adjust 90 to your desired percentage + language: system + pass_filenames: false # The command doesn't need specific filenames + always_run: true # This hook should always run + types: [python] # Only run if Python files are staged (adjust if needed) + files: '\.py$' # Trigger on Python files (adjust regex if you have other relevant files)