代码拉取完成,页面将自动刷新
# 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.11.12
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 --write
files: ^.github/.*\.(yml|yaml)$
language: node
pass_filenames: false
- id: license-headers
name: Checks that all files have the required license headers
entry: ./scripts/check_license_headers.py
language: system
always_run: true
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://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
exclude: .vscode/launch.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$
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。