streamlit
/
.pre-commit-config.yaml
199 строк · 6.6 Кб
1# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Pre-commit configuration file,
16# when Streamlit's pre-commit detects that one of the linters has failed,
17# it automatically lints the files and does not allow the commit to pass.
18# Please review the changes after lint has failed and commit them again,
19# the second commit should pass,
20# because the files were linted after trying to do the first commit.
21repos:
22- repo: https://github.com/psf/black
23rev: 22.6.0
24hooks:
25- id: black
26args:
27# Configure Black to support only syntax supported by the minimum supported Python version in setup.py.
28- --target-version=py37
29files: \.py$|\.pyi$
30exclude: ^e2e_flaky/.*
31- repo: https://github.com/PyCQA/isort
32rev: 5.11.5
33hooks:
34- id: isort
35args:
36- --filter-files
37exclude: ^lib/streamlit/__init__\.py$
38- repo: https://github.com/PyCQA/autoflake
39rev: v1.7.7
40hooks:
41- id: autoflake
42args:
43- "--in-place"
44- "--ignore-init-module-imports"
45- "--ignore-pass-after-docstring"
46- "--remove-unused-variables"
47additional_dependencies:
48- pyflakes==3.0.1
49- repo: local
50hooks:
51# Script ./scripts/run_in_subdirectory.py was used to work around a
52# known problem with hooks in subdirectories when pass_filenames option
53# is set to true
54# See: https://github.com/pre-commit/pre-commit/issues/1417
55- id: prettier
56name: Prettier
57entry: ./scripts/run_in_subdirectory.py frontend/ yarn prettier --write
58files: ^frontend/.*\.(js|jsx|ts|tsx)$
59exclude: /vendor/
60language: node
61pass_filenames: true
62- id: prettier-yaml
63name: Prettier-yaml
64entry: ./scripts/run_in_subdirectory.py frontend yarn prettier ../.github --write
65files: ^.github/.*\.(yml|yaml)$
66language: node
67pass_filenames: false
68# Typecheck will be run on CI using --hook-stage manual flag,
69# check out .github/workflows/js-tests.yml "Run linters" step for details.
70- id: typecheck-app
71name: Typecheck App
72always_run: true
73entry: yarn --cwd frontend/app tsc --noEmit
74files: \.(js|jsx|ts|tsx)$
75language: node
76pass_filenames: false
77stages:
78- manual
79- id: typecheck-lib
80name: Typecheck Lib
81always_run: true
82# no noEmit flag bc tsconfig.json emitDeclaration key is used
83entry: yarn --cwd frontend/lib tsc
84files: \.(js|jsx|ts|tsx)$
85language: node
86pass_filenames: false
87stages:
88- manual
89# Eslint will be run on CI using Makefile,
90# check out .github/workflows/js-tests.yml "Run linters" step for details.
91- id: eslint
92name: Eslint
93always_run: true
94entry: ./scripts/run_in_subdirectory.py frontend/ yarn lint --fix
95files: ^frontend/src/.*\.(js|jsx|ts|tsx)$
96language: node
97pass_filenames: true
98stages:
99- manual
100- id: license-headers
101name: Checks that all files have the required license headers
102entry: ./scripts/check_license_headers.py
103language: system
104always_run: true
105pass_filenames: false
106- id: no-relative-imports
107language: pygrep
108name: No relative imports
109description: Streamlit style is to use absolute imports only (except docs building)
110entry: "^\\s*from\\s+\\."
111pass_filenames: true
112files: \.py$
113- repo: https://github.com/Lucas-C/pre-commit-hooks
114rev: v1.5.4
115hooks:
116- id: insert-license
117name: Add license for all (S)CSS/JS(X)/TS(X) files
118files: \.(s?css|jsx?|tsx?)$
119args:
120- --comment-style
121- "/**| *| */"
122- --license-filepath
123- scripts/license-template.txt
124- --fuzzy-match-generates-todo
125exclude: |
126(?x)
127/vendor/
128|^vendor/
129|^component-lib/declarations/apache-arrow
130|^frontend/app/src/assets/css/variables\.scss
131- id: insert-license
132name: Add license for all Proto files
133files: \.proto$
134args:
135- --comment-style
136- "/**!| *| */"
137- --license-filepath
138- scripts/license-template.txt
139- --fuzzy-match-generates-todo
140exclude: |
141(?x)
142/vendor/
143|^vendor/
144|^component-lib/declarations/apache-arrow
145|^proto/streamlit/proto/openmetrics_data_model\.proto
146- id: insert-license
147name: Add license for all shell files
148files: \.sh$
149args:
150- --comment-style
151- "|#|"
152- --license-filepath
153- scripts/license-template.txt
154- --fuzzy-match-generates-todo
155exclude: |
156(?x)
157/vendor/
158|^vendor/
159|^component-lib/declarations/apache-arrow
160- id: insert-license
161name: Add license for all Python files
162files: \.py$|\.pyi$
163args:
164- --comment-style
165- "|#|"
166- --license-filepath
167- scripts/license-template.txt
168- --fuzzy-match-generates-todo
169exclude: |
170(?x)
171/vendor/
172|^vendor/
173|^component-lib/declarations/apache-arrow
174|^lib/tests/isolated_asyncio_test_case\.py$
175|^e2e_flaky/.*
176- id: insert-license
177name: Add license for all HTML files
178files: \.html$
179args:
180- --comment-style
181- "<!--||-->"
182- --license-filepath
183- scripts/license-template.txt
184- --fuzzy-match-generates-todo
185exclude: |
186(?x)
187/vendor/
188|^vendor/
189|^component-lib/declarations/apache-arrow
190- repo: https://github.com/pre-commit/pre-commit-hooks
191rev: v4.3.0
192hooks:
193- id: trailing-whitespace
194exclude: |
195(?x)
196^frontend/app/src/assets/
197|^NOTICES$
198|^proto/streamlit/proto/openmetrics_data_model.proto$
199|\.snap$
200