2025-04-01 16:41:30 +01:00
default_install_hook_types :
- pre-commit
- commit-msg
2025-01-20 17:36:24 +08:00
default_stages :
- pre-commit # Run locally
- manual # Run in CI
2025-02-27 16:27:47 +00:00
exclude : 'vllm/third_party/.*'
2025-01-20 06:58:01 +00:00
repos :
- repo : https://github.com/astral-sh/ruff-pre-commit
2025-10-10 18:03:44 +01:00
rev : v0.14.0
2025-01-20 06:58:01 +00:00
hooks :
2025-10-05 17:50:50 +01:00
- id : ruff-check
2025-02-13 02:45:38 -05:00
args : [ --output-format, github, --fix]
2025-05-13 10:28:31 +01:00
- id : ruff-format
2025-06-12 10:57:10 +08:00
- repo : https://github.com/crate-ci/typos
2025-10-10 18:03:44 +01:00
rev : v1.38.1
2025-01-20 06:58:01 +00:00
hooks :
2025-06-12 10:57:10 +08:00
- id : typos
2025-10-14 11:05:15 +01:00
args : [ --force-exclude]
2025-01-20 06:58:01 +00:00
- repo : https://github.com/pre-commit/mirrors-clang-format
2025-10-10 18:03:44 +01:00
rev : v21.1.2
2025-01-20 06:58:01 +00:00
hooks :
- id : clang-format
2025-02-09 15:00:00 +08:00
exclude : 'csrc/(moe/topk_softmax_kernels.cu|quantization/gguf/(ggml-common.h|dequantize.cuh|vecdotq.cuh|mmq.cuh|mmvq.cuh))|vllm/third_party/.*'
2025-01-20 06:58:01 +00:00
types_or : [ c++, cuda]
args : [ --style=file, --verbose]
2025-07-30 03:45:08 +01:00
- repo : https://github.com/igorshubovych/markdownlint-cli
rev : v0.45.0
2025-01-20 06:58:01 +00:00
hooks :
2025-07-30 22:17:14 +08:00
- id : markdownlint
2025-05-23 11:09:53 +02:00
exclude : '.*\.inc\.md'
2025-07-30 22:17:14 +08:00
stages : [ manual] # Only run in CI
2025-01-20 18:06:24 +08:00
- repo : https://github.com/rhysd/actionlint
2025-01-28 00:23:08 +00:00
rev : v1.7.7
2025-01-20 18:06:24 +08:00
hooks :
- id : actionlint
2025-02-21 06:03:27 +00:00
- repo : https://github.com/astral-sh/uv-pre-commit
2025-10-10 18:03:44 +01:00
rev : 0.9 .1
2025-02-21 06:03:27 +00:00
hooks :
- id : pip-compile
2025-11-09 13:07:26 +08:00
args : [ requirements/test.in, -o, requirements/test.txt, --index-strategy, unsafe-best-match, --torch-backend, cu129, --python-platform, x86_64-manylinux_2_28, --python-version, "3.12"]
2025-03-08 17:44:35 +01:00
files : ^requirements/test\.(in|txt)$
2025-01-20 06:58:01 +00:00
- repo : local
hooks :
2025-06-26 20:55:25 -07:00
- id : format-torch-nightly-test
name : reformat nightly_torch_test.txt to be in sync with test.in
language : python
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/generate_nightly_torch_test.py
2025-06-26 20:55:25 -07:00
files : ^requirements/test\.(in|txt)$
2025-01-20 17:36:24 +08:00
- id : mypy-local
2025-10-23 13:07:44 +01:00
name : Run mypy locally for lowest supported Python version
entry : python tools/pre_commit/mypy.py 0 "3.10"
2025-01-20 17:36:24 +08:00
stages : [ pre-commit] # Don't run in CI
2025-09-22 13:23:45 +01:00
<< : &mypy_common
language : python
types_or : [ python, pyi]
require_serial : true
additional_dependencies : [ mypy==1.11.1, regex, types-cachetools, types-setuptools, types-PyYAML, types-requests, types-torch, pydantic]
2025-01-20 06:58:01 +00:00
- id: mypy-3.10 # TODO : Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name : Run mypy for Python 3.10
2025-09-22 13:23:45 +01:00
entry : python tools/pre_commit/mypy.py 1 "3.10"
<< : *mypy_common
2025-01-20 17:36:24 +08:00
stages : [ manual] # Only run in CI
2025-01-20 06:58:01 +00:00
- id: mypy-3.11 # TODO : Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name : Run mypy for Python 3.11
2025-09-22 13:23:45 +01:00
entry : python tools/pre_commit/mypy.py 1 "3.11"
<< : *mypy_common
2025-01-20 17:36:24 +08:00
stages : [ manual] # Only run in CI
2025-01-20 06:58:01 +00:00
- id: mypy-3.12 # TODO : Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name : Run mypy for Python 3.12
2025-09-22 13:23:45 +01:00
entry : python tools/pre_commit/mypy.py 1 "3.12"
<< : *mypy_common
2025-01-20 17:36:24 +08:00
stages : [ manual] # Only run in CI
2025-10-08 18:40:42 +01:00
- id: mypy-3.13 # TODO : Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name : Run mypy for Python 3.13
entry : python tools/pre_commit/mypy.py 1 "3.13"
<< : *mypy_common
stages : [ manual] # Only run in CI
2025-01-20 06:58:01 +00:00
- id : shellcheck
name : Lint shell scripts
2025-10-29 16:04:33 +08:00
entry : tools/pre_commit/shellcheck.sh
2025-01-20 06:58:01 +00:00
language : script
types : [ shell]
- id : png-lint
name : Lint PNG exports from excalidraw
2025-10-29 16:04:33 +08:00
entry : tools/pre_commit/png-lint.sh
2025-01-20 06:58:01 +00:00
language : script
types : [ png]
2025-01-31 12:30:33 -08:00
- id : signoff-commit
name : Sign-off Commit
entry : bash
args :
- -c
- |
2025-05-05 13:55:32 -04:00
if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)"
2025-01-31 12:30:33 -08:00
fi
language : system
verbose : true
stages : [ commit-msg]
2025-02-02 14:58:18 -05:00
- id : check-spdx-header
name : Check SPDX headers
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/check_spdx_header.py
2025-02-02 14:58:18 -05:00
language : python
types : [ python]
2025-06-22 19:11:22 -04:00
- id : check-root-lazy-imports
name : Check root lazy imports
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/check_init_lazy_imports.py
2025-06-22 19:11:22 -04:00
language : python
types : [ python]
2025-02-06 15:36:21 -08:00
- id : check-filenames
name : Check for spaces in all filenames
2025-02-07 05:04:39 -08:00
entry : bash
args :
- -c
- 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0'
2025-02-06 15:36:21 -08:00
language : system
always_run : true
pass_filenames : false
2025-04-10 21:43:05 +08:00
- id : update-dockerfile-graph
name : Update Dockerfile dependency graph
2025-10-29 16:04:33 +08:00
entry : tools/pre_commit/update-dockerfile-graph.sh
2025-04-10 21:43:05 +08:00
language : script
2025-05-24 11:04:14 -04:00
- id : enforce-import-regex-instead-of-re
name : Enforce import regex as re
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/enforce_regex_import.py
2025-05-24 11:04:14 -04:00
language : python
types : [ python]
pass_filenames : false
additional_dependencies : [ regex]
2025-05-24 20:09:15 +08:00
# forbid directly import triton
- id : forbid-direct-triton-import
name : "Forbid direct 'import triton'"
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/check_triton_import.py
2025-05-24 20:09:15 +08:00
language : python
types : [ python]
pass_filenames : false
2025-05-27 17:19:18 +08:00
additional_dependencies : [ regex]
2025-06-12 06:30:17 -04:00
- id : check-pickle-imports
name : Prevent new pickle/cloudpickle imports
2025-09-22 12:08:25 +01:00
entry : python tools/pre_commit/check_pickle_imports.py
2025-06-12 06:30:17 -04:00
language : python
types : [ python]
2025-09-22 12:08:25 +01:00
additional_dependencies : [ regex]
2025-07-01 05:10:28 -04:00
- id : validate-config
name : Validate configuration has default values and that each field has a docstring
2025-10-29 16:04:33 +08:00
entry : python tools/pre_commit/validate_config.py
2025-07-01 05:10:28 -04:00
language : python
2025-09-18 13:06:28 +01:00
additional_dependencies : [ regex]
2026-01-17 19:15:30 +05:30
- id : validate-docker-versions
name : Validate docker/versions.json matches Dockerfile
entry : python tools/generate_versions_json.py --check
language : python
files : ^docker/(Dockerfile|versions\.json)$
pass_filenames : false
additional_dependencies : [ dockerfile-parse]
2025-02-11 17:34:16 -05:00
# Keep `suggestion` last
- id : suggestion
name : Suggestion
2025-07-07 10:42:06 +08:00
entry : bash -c 'echo "To bypass all the pre-commit hooks, add --no-verify to git commit. To skip a specific hook, prefix the commit command with SKIP=<hook-id>."'
2025-02-11 17:34:16 -05:00
language : system
verbose : true
pass_filenames : false
# Insert new entries above the `suggestion` entry