Add .pre-commit-config.yaml

This commit is contained in:
2025-07-06 17:41:46 +00:00
parent abfef34cf0
commit b3548b4632

40
.pre-commit-config.yaml Normal file
View File

@@ -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)