.pre-commit-config.yaml 5.8 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/astral-sh/ruff-pre-commit
10
  rev: v0.14.0
11
  hooks:
12
  - id: ruff-check
13
    args: [--output-format, github, --fix]
14
  - id: ruff-format
15
- repo: https://github.com/crate-ci/typos
16
  rev: v1.38.1
17
  hooks:
18
  - id: typos
19
    args: [--force-exclude]
20
- repo: https://github.com/pre-commit/mirrors-clang-format
21
  rev: v21.1.2
22
23
  hooks:
  - id: clang-format
24
    exclude: 'csrc/(moe/topk_softmax_kernels.cu|quantization/gguf/(ggml-common.h|dequantize.cuh|vecdotq.cuh|mmq.cuh|mmvq.cuh))|vllm/third_party/.*'
25
26
    types_or: [c++, cuda]
    args: [--style=file, --verbose]
27
28
- repo: https://github.com/igorshubovych/markdownlint-cli
  rev: v0.45.0
29
  hooks:
30
  - id: markdownlint
31
    exclude: '.*\.inc\.md'
32
    stages: [manual] # Only run in CI
33
- repo: https://github.com/rhysd/actionlint
34
  rev: v1.7.7
35
36
  hooks:
  - id: actionlint
37
- repo: https://github.com/astral-sh/uv-pre-commit
38
  rev: 0.9.1
39
40
  hooks:
    - id: pip-compile
41
      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"]
42
      files: ^requirements/test\.(in|txt)$
43
44
- repo: local
  hooks:
45
46
47
  - id: format-torch-nightly-test
    name: reformat nightly_torch_test.txt to be in sync with test.in
    language: python
48
    entry: python tools/pre_commit/generate_nightly_torch_test.py
49
    files: ^requirements/test\.(in|txt)$
50
  - id: mypy-local
51
52
    name: Run mypy locally for lowest supported Python version
    entry: python tools/pre_commit/mypy.py 0 "3.10"
53
    stages: [pre-commit] # Don't run in CI
54
55
56
57
58
    <<: &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]
59
60
  - 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
61
62
    entry: python tools/pre_commit/mypy.py 1 "3.10"
    <<: *mypy_common
63
    stages: [manual] # Only run in CI
64
65
  - 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
66
67
    entry: python tools/pre_commit/mypy.py 1 "3.11"
    <<: *mypy_common
68
    stages: [manual] # Only run in CI
69
70
  - 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
71
72
    entry: python tools/pre_commit/mypy.py 1 "3.12"
    <<: *mypy_common
73
    stages: [manual] # Only run in CI
74
75
76
77
78
  - 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
79
80
  - id: shellcheck
    name: Lint shell scripts
81
    entry: tools/pre_commit/shellcheck.sh
82
83
84
85
    language: script
    types: [shell]
  - id: png-lint
    name: Lint PNG exports from excalidraw
86
    entry: tools/pre_commit/png-lint.sh
87
88
    language: script
    types: [png]
89
90
91
92
93
94
  - id: signoff-commit
    name: Sign-off Commit
    entry: bash
    args:
      - -c
      - |
95
96
        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)"
97
98
99
100
        fi
    language: system
    verbose: true
    stages: [commit-msg]
101
102
  - id: check-spdx-header
    name: Check SPDX headers
103
    entry: python tools/pre_commit/check_spdx_header.py
104
105
    language: python
    types: [python]
106
107
  - id: check-root-lazy-imports
    name: Check root lazy imports
108
    entry: python tools/pre_commit/check_init_lazy_imports.py
109
110
    language: python
    types: [python]
111
112
  - id: check-filenames
    name: Check for spaces in all filenames
113
114
115
116
    entry: bash
    args:
      - -c
      - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0'
117
118
119
    language: system
    always_run: true
    pass_filenames: false
120
121
  - id: update-dockerfile-graph
    name: Update Dockerfile dependency graph
122
    entry: tools/pre_commit/update-dockerfile-graph.sh
123
    language: script
124
125
126
  - id: check-forbidden-imports
    name: Check for forbidden imports
    entry: python tools/pre_commit/check_forbidden_imports.py
127
128
    language: python
    types: [python]
129
    additional_dependencies: [regex]
130
131
  - id: validate-config
    name: Validate configuration has default values and that each field has a docstring
132
    entry: python tools/pre_commit/validate_config.py
133
    language: python
134
    additional_dependencies: [regex]
135
136
137
138
139
140
141
  - 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]
142
143
144
145
  - id: attention-backend-docs
    name: Check attention backend documentation is up to date
    entry: python tools/pre_commit/generate_attention_backend_docs.py --check
    language: python
146
147
148
149
150
  - id: check-boolean-context-manager
    name: Check for boolean ops in with-statements
    entry: python tools/pre_commit/check_boolean_context_manager.py
    language: python
    types: [python]
151
152
153
  # Keep `suggestion` last
  - id: suggestion
    name: Suggestion
154
    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>."'
155
156
157
158
    language: system
    verbose: true
    pass_filenames: false
  # Insert new entries above the `suggestion` entry