.pre-commit-config.yaml 4.93 KB
Newer Older
1
2
3
default_install_hook_types:
  - pre-commit
  - commit-msg
4
5
6
default_stages:
  - pre-commit # Run locally
  - manual # Run in CI
7
exclude: 'vllm/third_party/.*'
8
9
repos:
- repo: https://github.com/google/yapf
10
  rev: v0.43.0
11
12
13
14
  hooks:
  - id: yapf
    args: [--in-place, --verbose]
- repo: https://github.com/astral-sh/ruff-pre-commit
15
  rev: v0.11.7
16
17
  hooks:
  - id: ruff
18
    args: [--output-format, github, --fix]
19
  - id: ruff-format
20
    files: ^(.buildkite|benchmarks|examples)/.*
21
- repo: https://github.com/codespell-project/codespell
22
  rev: v2.4.1
23
24
  hooks:
  - id: codespell
25
26
    additional_dependencies: ['tomli']
    args: ['--toml', 'pyproject.toml']
27
- repo: https://github.com/PyCQA/isort
28
  rev: 6.0.1
29
30
31
  hooks:
  - id: isort
- repo: https://github.com/pre-commit/mirrors-clang-format
32
  rev: v20.1.3
33
34
  hooks:
  - id: clang-format
35
    exclude: 'csrc/(moe/topk_softmax_kernels.cu|quantization/gguf/(ggml-common.h|dequantize.cuh|vecdotq.cuh|mmq.cuh|mmvq.cuh))|vllm/third_party/.*'
36
37
38
    types_or: [c++, cuda]
    args: [--style=file, --verbose]
- repo: https://github.com/jackdewinter/pymarkdown
39
  rev: v0.9.29
40
41
  hooks:
  - id: pymarkdown
42
    exclude: '.*\.inc\.md'
43
    args: [fix]
44
- repo: https://github.com/rhysd/actionlint
45
  rev: v1.7.7
46
47
  hooks:
  - id: actionlint
48
- repo: https://github.com/astral-sh/uv-pre-commit
49
  rev: 0.6.17
50
51
  hooks:
    - id: pip-compile
52
      args: [requirements/test.in, -o, requirements/test.txt, --index-strategy, unsafe-best-match, --torch-backend, cu128]
53
      files: ^requirements/test\.(in|txt)$
54
55
- repo: local
  hooks:
56
57
  - id: mypy-local
    name: Run mypy for local Python installation
58
    entry: tools/mypy.sh 0 "local"
59
60
    language: python
    types: [python]
61
    additional_dependencies: &mypy_deps [mypy==1.11.1, types-cachetools, types-setuptools, types-PyYAML, types-requests, pydantic]
62
    stages: [pre-commit] # Don't run in CI
63
64
65
66
67
  - id: mypy-3.9 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
    name: Run mypy for Python 3.9
    entry: tools/mypy.sh 1 "3.9"
    language: python
    types: [python]
68
69
    additional_dependencies: *mypy_deps
    stages: [manual] # Only run in CI
70
71
72
73
74
75
  - 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
    entry: tools/mypy.sh 1 "3.10"
    language: python
    types: [python]
    additional_dependencies: *mypy_deps
76
    stages: [manual] # Only run in CI
77
78
79
80
81
82
  - 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
    entry: tools/mypy.sh 1 "3.11"
    language: python
    types: [python]
    additional_dependencies: *mypy_deps
83
    stages: [manual] # Only run in CI
84
85
86
87
88
89
  - 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
    entry: tools/mypy.sh 1 "3.12"
    language: python
    types: [python]
    additional_dependencies: *mypy_deps
90
    stages: [manual] # Only run in CI
91
92
93
94
95
96
97
98
99
100
  - id: shellcheck
    name: Lint shell scripts
    entry: tools/shellcheck.sh
    language: script
    types: [shell]
  - id: png-lint
    name: Lint PNG exports from excalidraw
    entry: tools/png-lint.sh
    language: script
    types: [png]
101
102
103
104
105
106
  - id: signoff-commit
    name: Sign-off Commit
    entry: bash
    args:
      - -c
      - |
107
108
        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)"
109
110
111
112
        fi
    language: system
    verbose: true
    stages: [commit-msg]
113
114
115
116
117
  - id: check-spdx-header
    name: Check SPDX headers
    entry: python tools/check_spdx_header.py
    language: python
    types: [python]
118
119
  - id: check-filenames
    name: Check for spaces in all filenames
120
121
122
123
    entry: bash
    args:
      - -c
      - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0'
124
125
126
    language: system
    always_run: true
    pass_filenames: false
127
128
129
130
  - id: update-dockerfile-graph
    name: Update Dockerfile dependency graph
    entry: tools/update-dockerfile-graph.sh
    language: script
131
132
133
134
135
136
137
  - id: enforce-import-regex-instead-of-re
    name: Enforce import regex as re
    entry: python tools/enforce_regex_import.py
    language: python
    types: [python]
    pass_filenames: false
    additional_dependencies: [regex]
138
139
140
141
142
143
144
  # forbid directly import triton
  - id: forbid-direct-triton-import
    name: "Forbid direct 'import triton'"
    entry: python tools/check_triton_import.py
    language: python
    types: [python]
    pass_filenames: false
145
    additional_dependencies: [regex]
146
147
148
149
150
151
152
153
  # Keep `suggestion` last
  - id: suggestion
    name: Suggestion
    entry: bash -c 'echo "To bypass pre-commit hooks, add --no-verify to git commit."'
    language: system
    verbose: true
    pass_filenames: false
  # Insert new entries above the `suggestion` entry