forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
242 lines (241 loc) · 9.46 KB
/
.pre-commit-config.yaml
File metadata and controls
242 lines (241 loc) · 9.46 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
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2025)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Pre-commit configuration file,
# when Streamlit's pre-commit detects that one of the linters has failed,
# it automatically lints the files and does not allow the commit to pass.
# Please review the changes after lint has failed and commit them again,
# the second commit should pass,
# because the files were linted after trying to do the first commit.
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# We fix ruff to a version to be in sync with the dev-requirements:
rev: v0.14.5
hooks:
# Run the linter.
- id: ruff
args: [--fix]
files: \.py$|\.pyi$
# Run the formatter.
- id: ruff-format
files: \.py$|\.pyi$
- repo: local
hooks:
# Script ./scripts/run_in_subdirectory.py was used to work around a
# known problem with hooks in subdirectories when pass_filenames option
# is set to true
# See: https://github.com/pre-commit/pre-commit/issues/1417
- id: prettier-app
name: Prettier App
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
entry: ./scripts/run_in_subdirectory.py frontend/app yarn run format
files: ^frontend/app/.*\.(js|jsx|ts|tsx)$
exclude: /vendor/
language: node
pass_filenames: true
- id: prettier-lib
name: Prettier Lib
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
entry: ./scripts/run_in_subdirectory.py frontend/lib yarn run format
files: ^frontend/lib/.*\.(js|jsx|ts|tsx)$
exclude: /vendor/
language: node
pass_filenames: true
- id: prettier-connection
name: Prettier Connection
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
entry: ./scripts/run_in_subdirectory.py frontend/connection yarn run format
files: ^frontend/connection/.*\.(js|jsx|ts|tsx)$
exclude: /vendor/
language: node
pass_filenames: true
- id: prettier-utils
name: Prettier Utils
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
entry: ./scripts/run_in_subdirectory.py frontend/utils yarn run format
files: ^frontend/utils/.*\.(js|jsx|ts|tsx)$
exclude: /vendor/
language: node
pass_filenames: true
- id: prettier-yaml
name: Prettier-yaml
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
# We perform this in the app directory because prettier is installed there. TODO: Break this out to a new package
entry: ./scripts/run_in_subdirectory.py frontend/app yarn prettier "../../.github/**/*.{yml,yaml}" --write
files: ^.github/.*\.(yml|yaml)$
language: node
pass_filenames: false
- id: prettier-vscode-devcontainer-json
name: Prettier VSCode/devcontainer JSON
# NOTE: This hook currently does not work on Windows due to "yarn" not being an executable and win32api.CreateProcess
# turning `subprocess.run(["yarn", "prettier", "--write"])` into a call to `yarn.exe prettier --write` which does not exist
# We perform this in the app directory because prettier is installed there. TODO: Break this out to a new package
entry: ./scripts/run_in_subdirectory.py frontend/app yarn prettier "../../.vscode/*.json" "../../.devcontainer/*.json" --write --config ../.prettierrc
files: ^(.vscode/.*\.json|\.devcontainer/.*\.json)$
language: node
pass_filenames: false
- id: license-headers
name: Checks license headers
entry: ./scripts/check_license_headers.py
language: system
always_run: true
pass_filenames: false
- id: generate-agent-rules
name: Check generated agent rules
entry: ./scripts/generate_agent_rules.py
language: system
pass_filenames: false
files: |
(?x)
(^|.*/)AGENTS\.md$
|^scripts/generate_agent_rules\.py$
|^Makefile$
- id: vscode-devcontainer-sync
name: Check VSCode/devcontainer sync
entry: ./scripts/sync_vscode_devcontainer.py --check
language: system
files: ^(.vscode/(settings|extensions)\.json|\.devcontainer/devcontainer\.json)$
pass_filenames: false
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
name: Add license for all (S)CSS/JS(X)/TS(X) files
files: \.(s?css|jsx?|tsx?)$
args:
- --comment-style
- "/**| *| */"
- --license-filepath
- scripts/assets/license-template.txt
- --fuzzy-match-generates-todo
exclude: |
(?x)
/vendor/
|^vendor/
|^component-lib/declarations/apache-arrow
|^frontend/app/src/assets/css/variables\.scss
|^lib/tests/streamlit/elements/test_html\.js
|^lib/tests/streamlit/elements/test_html\.css
|^e2e_playwright/test_assets/
- id: insert-license
name: Add license for all Proto files
files: \.proto$
args:
- --comment-style
- "/**!| *| */"
- --license-filepath
- scripts/assets/license-template.txt
- --fuzzy-match-generates-todo
exclude: |
(?x)
/vendor/
|^vendor/
|^component-lib/declarations/apache-arrow
|^proto/streamlit/proto/openmetrics_data_model\.proto
- id: insert-license
name: Add license for all shell files
files: \.sh$
args:
- --comment-style
- "|#|"
- --license-filepath
- scripts/assets/license-template.txt
- --fuzzy-match-generates-todo
exclude: |
(?x)
/vendor/
|^vendor/
|^component-lib/declarations/apache-arrow
- id: insert-license
name: Add license for all Python files
files: \.py$|\.pyi$
args:
- --comment-style
- "|#|"
- --license-filepath
- scripts/assets/license-template.txt
- --fuzzy-match-generates-todo
exclude: |
(?x)
/vendor/
|^vendor/
|^component-lib/declarations/apache-arrow
- id: insert-license
name: Add license for all HTML files
files: \.html$
args:
- --comment-style
- "<!--||-->"
- --license-filepath
- scripts/assets/license-template.txt
- --fuzzy-match-generates-todo
exclude: |
(?x)
/vendor/
|^vendor/
|^component-lib/declarations/apache-arrow
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
# Check JSON files that are allowed to have comments
- id: check-json5
# Note that this should be the same as the check-json hook's exclude
# property
files: |
(?x)
^\.vscode/.*\.json$
|tsconfig.*\.json$
|.*tsconfig\.json$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: |
(?x)
^frontend/app/src/assets/
|^NOTICES$
|^proto/streamlit/proto/openmetrics_data_model.proto$
|\.snap$
- id: check-added-large-files
- id: check-json
# Note that this should be the same as the check-json5 hook's files
# property
exclude: |
(?x)
^\.vscode/.*\.json$
|tsconfig.*\.json$
|.*tsconfig\.json$
- id: check-toml
- id: check-yaml
exclude: lib/conda-recipe/meta.yaml
- id: check-symlinks
- id: check-case-conflict
- id: check-merge-conflict
- id: fix-byte-order-marker
- id: end-of-file-fixer
exclude: |
(?x)
/vendor/
|^NOTICES$
|^e2e_playwright/test_assets/
|^LICENSE$
- id: mixed-line-ending
args: [--fix=lf]
exclude: |
(?x)
^NOTICES$