streamlit

Форк
0
/
.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.
21
repos:
22
  - repo: https://github.com/psf/black
23
    rev: 22.6.0
24
    hooks:
25
      - id: black
26
        args:
27
          # Configure Black to support only syntax supported by the minimum supported Python version in setup.py.
28
          - --target-version=py37
29
        files: \.py$|\.pyi$
30
        exclude: ^e2e_flaky/.*
31
  - repo: https://github.com/PyCQA/isort
32
    rev: 5.11.5
33
    hooks:
34
      - id: isort
35
        args:
36
          - --filter-files
37
        exclude: ^lib/streamlit/__init__\.py$
38
  - repo: https://github.com/PyCQA/autoflake
39
    rev: v1.7.7
40
    hooks:
41
      - id: autoflake
42
        args:
43
          - "--in-place"
44
          - "--ignore-init-module-imports"
45
          - "--ignore-pass-after-docstring"
46
          - "--remove-unused-variables"
47
        additional_dependencies:
48
          - pyflakes==3.0.1
49
  - repo: local
50
    hooks:
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
56
        name: Prettier
57
        entry: ./scripts/run_in_subdirectory.py frontend/ yarn prettier --write
58
        files: ^frontend/.*\.(js|jsx|ts|tsx)$
59
        exclude: /vendor/
60
        language: node
61
        pass_filenames: true
62
      - id: prettier-yaml
63
        name: Prettier-yaml
64
        entry: ./scripts/run_in_subdirectory.py frontend yarn prettier ../.github --write
65
        files: ^.github/.*\.(yml|yaml)$
66
        language: node
67
        pass_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
71
        name: Typecheck App
72
        always_run: true
73
        entry: yarn --cwd frontend/app tsc --noEmit
74
        files: \.(js|jsx|ts|tsx)$
75
        language: node
76
        pass_filenames: false
77
        stages:
78
          - manual
79
      - id: typecheck-lib
80
        name: Typecheck Lib
81
        always_run: true
82
        # no noEmit flag bc tsconfig.json emitDeclaration key is used
83
        entry: yarn --cwd frontend/lib tsc
84
        files: \.(js|jsx|ts|tsx)$
85
        language: node
86
        pass_filenames: false
87
        stages:
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
92
        name: Eslint
93
        always_run: true
94
        entry: ./scripts/run_in_subdirectory.py frontend/ yarn lint --fix
95
        files: ^frontend/src/.*\.(js|jsx|ts|tsx)$
96
        language: node
97
        pass_filenames: true
98
        stages:
99
          - manual
100
      - id: license-headers
101
        name: Checks that all files have the required license headers
102
        entry: ./scripts/check_license_headers.py
103
        language: system
104
        always_run: true
105
        pass_filenames: false
106
      - id: no-relative-imports
107
        language: pygrep
108
        name: No relative imports
109
        description: Streamlit style is to use absolute imports only (except docs building)
110
        entry: "^\\s*from\\s+\\."
111
        pass_filenames: true
112
        files: \.py$
113
  - repo: https://github.com/Lucas-C/pre-commit-hooks
114
    rev: v1.5.4
115
    hooks:
116
      - id: insert-license
117
        name: Add license for all (S)CSS/JS(X)/TS(X) files
118
        files: \.(s?css|jsx?|tsx?)$
119
        args:
120
          - --comment-style
121
          - "/**| *| */"
122
          - --license-filepath
123
          - scripts/license-template.txt
124
          - --fuzzy-match-generates-todo
125
        exclude: |
126
          (?x)
127
          /vendor/
128
          |^vendor/
129
          |^component-lib/declarations/apache-arrow
130
          |^frontend/app/src/assets/css/variables\.scss
131
      - id: insert-license
132
        name: Add license for all Proto files
133
        files: \.proto$
134
        args:
135
          - --comment-style
136
          - "/**!| *| */"
137
          - --license-filepath
138
          - scripts/license-template.txt
139
          - --fuzzy-match-generates-todo
140
        exclude: |
141
          (?x)
142
          /vendor/
143
          |^vendor/
144
          |^component-lib/declarations/apache-arrow
145
          |^proto/streamlit/proto/openmetrics_data_model\.proto
146
      - id: insert-license
147
        name: Add license for all shell files
148
        files: \.sh$
149
        args:
150
          - --comment-style
151
          - "|#|"
152
          - --license-filepath
153
          - scripts/license-template.txt
154
          - --fuzzy-match-generates-todo
155
        exclude: |
156
          (?x)
157
          /vendor/
158
          |^vendor/
159
          |^component-lib/declarations/apache-arrow
160
      - id: insert-license
161
        name: Add license for all Python files
162
        files: \.py$|\.pyi$
163
        args:
164
          - --comment-style
165
          - "|#|"
166
          - --license-filepath
167
          - scripts/license-template.txt
168
          - --fuzzy-match-generates-todo
169
        exclude: |
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
177
        name: Add license for all HTML files
178
        files: \.html$
179
        args:
180
          - --comment-style
181
          - "<!--||-->"
182
          - --license-filepath
183
          - scripts/license-template.txt
184
          - --fuzzy-match-generates-todo
185
        exclude: |
186
          (?x)
187
          /vendor/
188
          |^vendor/
189
          |^component-lib/declarations/apache-arrow
190
  - repo: https://github.com/pre-commit/pre-commit-hooks
191
    rev: v4.3.0
192
    hooks:
193
      - id: trailing-whitespace
194
        exclude: |
195
          (?x)
196
          ^frontend/app/src/assets/
197
          |^NOTICES$
198
          |^proto/streamlit/proto/openmetrics_data_model.proto$
199
          |\.snap$
200

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.