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