Files
unstract/.pre-commit-config.yaml
2024-02-25 16:19:36 +05:30

201 lines
5.9 KiB
YAML

---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# - Added unstract feature flag auto generated code to flake8 exclude list
# Force all unspecified python hooks to run python 3.10
default_language_version:
python: python3.9
default_stages:
- commit
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types:
- "markdown"
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- id: check-added-large-files
args: ["--maxkb=10240"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-ast
- id: check-json
exclude: ".vscode/launch.json"
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: debug-statements
- id: detect-private-key
- id: check-merge-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: forbid-new-submodules
- id: mixed-line-ending
- id: no-commit-to-branch
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: ["-d", "relaxed"]
language: system
- repo: https://github.com/rhysd/actionlint
rev: v1.6.26
hooks:
- id: actionlint-docker
args: [-ignore, 'label ".+" is unknown']
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
args: [--config=pyproject.toml, -l 80]
language: system
exclude: |
(?x)^(
unstract/flags/src/unstract/flags/evaluation_.*\.py|
)$
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--max-line-length=80]
exclude: |
(?x)^(
.*migrations/.*\.py|
core/tests/.*|
unstract/flags/src/unstract/flags/evaluation_.*\.py|
)$
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
files: "\\.(py)$"
args:
[
"--profile",
"black",
"--filter-files",
--settings-path=pyproject.toml,
]
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
args: [--config=pyproject.toml]
- repo: https://github.com/pycqa/docformatter
rev: v1.7.5
hooks:
- id: docformatter
# - repo: https://github.com/MarcoGorelli/absolufy-imports
# rev: v0.3.1
# hooks:
# - id: absolufy-imports
# files: ^backend/
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
entry: pyupgrade --py39-plus --keep-runtime-typing
types:
- python
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.2
hooks:
- id: gitleaks
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint-docker
args:
- --ignore=DL3003
- --ignore=DL3008
- --ignore=DL3013
- --ignore=DL3018
- --ignore=SC1091
files: Dockerfile$
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v9.0.0-beta.0" # Use the sha / tag you want to point at
hooks:
- id: eslint
args: [--config=frontend/.eslintrc.json]
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [file]
additional_dependencies:
- eslint@8.41.0
- eslint-config-google@0.14.0
- eslint-config-prettier@8.8.0
- eslint-plugin-prettier@4.2.1
- eslint-plugin-react@7.32.2
- eslint-plugin-import@2.25.2
- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
rev: v1.1.2
hooks:
- id: htmlhint
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
entry: pyupgrade --py38-plus --keep-runtime-typing
types:
- python
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
language: system
entry: mypy .
pass_filenames: false
# IMPORTANT!
# Keep args same as tool.mypy section in pyproject.toml
args:
[
--allow-subclassing-any,
--allow-untyped-decorators,
--check-untyped-defs,
--exclude, ".*migrations/.*.py",
--exclude, "backend/prompt/.*",
--exclude, "document-service/.*",
--exclude, "unstract/connectors/tests/.*",
--exclude, "unstract/core/.*",
--exclude, "unstract/flags/src/unstract/flags/.*",
--exclude, "__pypackages__/.*",
--follow-imports, "silent",
--ignore-missing-imports,
--implicit-reexport,
--pretty,
--python-version=3.9,
--show-column-numbers,
--show-error-codes,
--strict,
--warn-redundant-casts,
--warn-return-any,
--warn-unreachable,
--warn-unused-configs,
--warn-unused-ignores,
]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
args: [--disable, MD013]
- id: markdownlint-fix
args: [--disable, MD013]
- repo: https://github.com/pdm-project/pdm
rev: 2.12.3
hooks:
- id: pdm-lock-check
- repo: local
hooks:
- id: check-django-migrations
name: Check django migrations
entry: sh -c 'pdm run `find . -name "manage.py" -not -path "*/.venv/*"` makemigrations --check --dry-run --no-input'
language: system
types: [python] # hook only runs if a python file is staged
pass_filenames: false