feat: add pre-commit hooks
This commit is contained in:
parent
8df7d5faf8
commit
f45a28b6c6
|
@ -0,0 +1,66 @@
|
||||||
|
default_language_version:
|
||||||
|
python: python3.11
|
||||||
|
default_stages: [commit]
|
||||||
|
fail_fast: true
|
||||||
|
|
||||||
|
repos:
|
||||||
|
# Basic pre-commit hooks
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v2.3.0
|
||||||
|
hooks:
|
||||||
|
- id: check-xml
|
||||||
|
- id: check-yaml
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-ast
|
||||||
|
- id: debug-statements
|
||||||
|
- id: no-commit-to-branch
|
||||||
|
args: ['--branch', 'development', '--branch', 'staging', '--branch', 'production']
|
||||||
|
|
||||||
|
# Dependencies checker
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
|
||||||
|
rev: v1.3.2
|
||||||
|
hooks:
|
||||||
|
- id: python-safety-dependencies-check
|
||||||
|
files: common.txt, local.txt
|
||||||
|
|
||||||
|
# isort For sorting imports
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 5.12.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.4.4
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
name: ruff
|
||||||
|
entry: ruff check --fix
|
||||||
|
language: python
|
||||||
|
- id: ruff-format
|
||||||
|
name: ruff-format
|
||||||
|
entry: ruff format
|
||||||
|
language: python
|
||||||
|
|
||||||
|
# Codespell for spell checking
|
||||||
|
# - repo: https://github.com/codespell-project/codespell
|
||||||
|
# rev: v2.2.4
|
||||||
|
# hooks:
|
||||||
|
# - id: codespell
|
||||||
|
# exclude: >
|
||||||
|
# (?x)^(
|
||||||
|
# .*\test_*.py
|
||||||
|
# )$
|
||||||
|
|
||||||
|
# Pytest for testing
|
||||||
|
# - repo: local
|
||||||
|
# hooks:
|
||||||
|
# - id: pytest-check
|
||||||
|
# stages: [commit]
|
||||||
|
# types: [python]
|
||||||
|
# name: pytest-check
|
||||||
|
# entry: pytest
|
||||||
|
# language: system
|
||||||
|
# pass_filenames: false
|
||||||
|
# always_run: true
|
|
@ -1,5 +1,16 @@
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 79
|
line-length = 79
|
||||||
target-version = ['py39']
|
target-version = ['py312']
|
||||||
include = '\.pyi?$'
|
include = '\.pyi?$'
|
||||||
extend-exclude = 'migrations/*'
|
extend-exclude = 'migrations/*'
|
||||||
|
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort]
|
||||||
|
case-sensitive = true
|
||||||
|
force-single-line = true
|
||||||
|
section-order = ["future", "standard-library", "first-party", "django", "rest_framework", "third-party", "local-folder"]
|
||||||
|
|
||||||
|
|
||||||
|
[tool.ruff.lint.isort.sections]
|
||||||
|
"django" = ["django"]
|
||||||
|
"rest_framework" = ["rest_framework"]
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
-r common.txt
|
-r common.txt
|
||||||
|
ruff
|
||||||
|
pre-commit
|
||||||
|
pytest-django
|
||||||
|
|
Loading…
Reference in New Issue