forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
276 lines (230 loc) · 7.38 KB
/
.pre-commit-config.yaml
File metadata and controls
276 lines (230 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# Exclude all third-party libraries and auto-generated files globally
exclude: |
(?x)^(
patches/.+|
paddle/fluid/framework/fleet/heter_ps/cudf/.+|
paddle/fluid/distributed/ps/thirdparty/round_robin.h|
python/paddle/utils/gast/.+|
third_party/.+
)$
repos:
# Common hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: sort-simple-yaml
files: (ops|backward|op_[a-z_]+)\.yaml$
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.5.1
hooks:
- id: remove-crlf
- id: remove-tabs
name: Tabs remover (C++)
files: \.(c|cc|cxx|cpp|cu|h|cuh|hpp|hxx|xpu|kps)$
args: [--whitespaces-count, '2']
- id: remove-tabs
name: Tabs remover (Python)
files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
args: [--whitespaces-count, '4']
# Exclude some unit test files that require tabs.
exclude: |
(?x)^(
test/dygraph_to_static/test_error.py
)$
- repo: local
hooks:
- id: copyright_checker
name: copyright_checker
entry: python ./tools/codestyle/copyright.py
language: system
files: \.(c|cc|cxx|cpp|cu|h|cuh|hpp|hxx|proto|xpu|kps|py|pyi|sh)$
exclude: |
(?x)^(
paddle/utils/.*|
paddle/cinn/utils/registry.h
)$
- repo: https://github.com/PFCCLab/typos-pre-commit-mirror.git
rev: v1.34.0
hooks:
- id: typos
args: [--force-exclude]
# For Python files
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
hooks:
- id: black
exclude: |
(?x)^(
ci/.+
| cmake/.+
| r/.+
| paddle/scripts/.+
| setup.py
# | paddle/.+
# | python/paddle/[a-c].+
# | python/paddle/de.+
# | python/paddle/distributed/a.+
# | python/paddle/distributed/[b-e].+
# | python/paddle/distributed/f.+
# | python/paddle/distributed/[g-z].+
# | python/paddle/[e-i].+
# | python/paddle/j.+
# | python/paddle/[k-n].+
# | python/paddle/[o-t].+
# | python/paddle/[u-z].+
# | python/_.+
# | test/a.+
# | test/[b-h].+
# | test/[i-k].+
# | test/l.+
# | test/[m-z].+
# | tools/.+
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- id: ruff-format
exclude: |
(?x)^(
# ci/.+
# | cmake/.+
# | r/.+
# | paddle/scripts/.+
# | setup.py
| paddle/.+
| python/paddle/[a-c].+
| python/paddle/de.+
| python/paddle/distributed/a.+
| python/paddle/distributed/[b-e].+
| python/paddle/distributed/f.+
| python/paddle/distributed/[g-z].+
| python/paddle/[e-i].+
| python/paddle/j.+
| python/paddle/[k-n].+
| python/paddle/[o-t].+
| python/paddle/[u-z].+
| python/_.+
| test/a.+
| test/[b-h].+
| test/[i-k].+
| test/l.+
| test/[m-z].+
| tools/.+
)$
# For C++ files
- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: bash ./tools/codestyle/clang_format.sh -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|cuh|hpp|hxx|xpu|kps)$
- repo: local
hooks:
- id: cpplint-cpp-source
name: cpplint
description: Check C++ code style using cpplint.py.
entry: bash ./tools/codestyle/cpplint_pre_commit.sh
language: system
files: \.(cc|cxx|cpp|cu|h|hpp|hxx)$
args:
- --extensions=cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps
- --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens
- --quiet
# Exclude third-party libraries
exclude: |
(?x)^(
paddle/utils/flat_hash_map\.h
)$
- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
description: Parallel clang-tidy runner.
entry: python ./tools/codestyle/clang-tidy.py
language: system
files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
args:
- -p=build/
- -extra-arg=-Wno-unknown-warning-option
- -extra-arg=-Wno-pessimizing-move
- -extra-arg=-Wno-braced-scalar-init
- -extra-arg=-Wno-dangling-gsl
- -extra-arg=-Wno-deprecated-copy
- -extra-arg=-Wno-final-dtor-non-final-class
- -extra-arg=-Wno-implicit-int-float-conversion
- -extra-arg=-Wno-inconsistent-missing-override
- -extra-arg=-Wno-infinite-recursion
- -extra-arg=-Wno-mismatched-tags
- -extra-arg=-Wno-self-assign
- -extra-arg=-Wno-sign-compare
- -extra-arg=-Wno-sometimes-uninitialized
- -extra-arg=-Wno-tautological-overlap-compare
- -extra-arg=-Wno-unused-const-variable
- -extra-arg=-Wno-unused-lambda-capture
- -extra-arg=-Wno-unused-private-field
- -extra-arg=-Wno-unused-value
- -extra-arg=-Wno-unused-variable
- -extra-arg=-Wno-overloaded-virtual
- -extra-arg=-Wno-defaulted-function-deleted
- -extra-arg=-Wno-delete-non-abstract-non-virtual-dtor
- -extra-arg=-Wno-return-type-c-linkage
# For CMake files
- repo: local
hooks:
- id: auto-generate-cmakelists
name: auto-generate-cmakelists
entry: bash ./tools/gen_ut_cmakelists.hook
language: system
files: testslist.csv$
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
# exclude paddle/fluid/operators/CMakeLists.txt, see the comment
# https://github.com/PaddlePaddle/Paddle/pull/43057#pullrequestreview-993471860
exclude: |
(?x)^(
paddle/fluid/operators/CMakeLists.txt
)$
- repo: https://github.com/PFCCLab/cmake-lint-paddle
rev: v1.5.1
hooks:
- id: cmakelint
args: [--config=./tools/codestyle/.cmakelintrc]
# Exclude some files has false positive warnings
# Need to fix them in the future
exclude: |
(?x)^(
cmake/external/onnxruntime.cmake
)$
# For YAML files
- repo: https://github.com/PFCCLab/yamlfmt-pre-commit-mirror.git
rev: v0.16.0
hooks:
- id: yamlfmt
files: |
(?x)^(
\.github/.+\.(yaml|yml)|
\.pre-commit-config\.yaml|
\.yamlfmt
)
# Others
- repo: local
hooks:
- id: sort-txt-file
name: sort-txt-file
description: Sorts each line string in a text file
entry: python ./tools/codestyle/sort_txt_file.py
language: python
files: test/white_list/pir_op_test_white_list
args: []