diff --git a/pre-commit-config.yml b/pre-commit-config.yml new file mode 100644 index 0000000..481f8fd --- /dev/null +++ b/pre-commit-config.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e337eb8..06932a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,16 @@ [tool.black] line-length = 79 -target-version = ['py39'] +target-version = ['py312'] include = '\.pyi?$' 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"] diff --git a/requirements/local.txt b/requirements/local.txt index c3899b0..29890c1 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -1 +1,4 @@ --r common.txt \ No newline at end of file +-r common.txt +ruff +pre-commit +pytest-django