-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add pre-commit config Signed-off-by: Sun, Xuehao <[email protected]> * add prettier Signed-off-by: Sun, Xuehao <[email protected]> * update prettier Signed-off-by: Sun, Xuehao <[email protected]> * fix codespell Signed-off-by: Sun, Xuehao <[email protected]> --------- Signed-off-by: Sun, Xuehao <[email protected]>
- Loading branch information
Showing
5 changed files
with
250 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright (c) 2024 Intel Corporation | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
ci: | ||
autofix_prs: true | ||
autoupdate_schedule: quarterly | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
files: (.*\.(py|md|rst|yaml|yml|json|ts|js|html|svelte|sh))$ | ||
- id: check-json | ||
exclude: | | ||
(?x)^( | ||
ChatQnA/ui/tsconfig.json | ||
)$ | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
files: (.*\.(py|rst|cmake|yaml|yml|json|ts|js|html|svelte|sh))$ | ||
|
||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.5.5 | ||
hooks: | ||
- id: insert-license | ||
files: | | ||
(?x)^( | ||
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(py|yaml|yml|sh)| | ||
)$ | ||
args: | ||
[ | ||
--license-filepath=.github/license_template.txt, | ||
--use-current-year, | ||
--detect-license-in-X-top-lines=40, | ||
--skip-license-insertion-comment=Copyright, | ||
] | ||
- id: insert-license | ||
files: | | ||
(?x)^( | ||
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(ts|js)| | ||
)$ | ||
args: | ||
[ | ||
--license-filepath=.github/license_template.txt, | ||
--use-current-year, | ||
--detect-license-in-X-top-lines=40, | ||
--skip-license-insertion-comment=Copyright, | ||
--comment-style=//, | ||
] | ||
- id: insert-license | ||
files: | | ||
(?x)^( | ||
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(html|svelte)| | ||
)$ | ||
args: | ||
[ | ||
--license-filepath=.github/license_template.txt, | ||
--use-current-year, | ||
--detect-license-in-X-top-lines=40, | ||
--skip-license-insertion-comment=Copyright, | ||
--comment-style=<!--| |-->, | ||
] | ||
|
||
- repo: https://github.com/asottile/yesqa | ||
rev: v1.5.0 | ||
hooks: | ||
- id: yesqa | ||
name: Unused noqa | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/PyCQA/docformatter | ||
rev: v1.7.5 | ||
hooks: | ||
- id: docformatter | ||
args: [ | ||
--in-place, | ||
--wrap-summaries=0, # 0 means disable wrap | ||
--wrap-descriptions=0, # 0 means disable wrap | ||
--black, | ||
--style=google, | ||
] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v3.1.0" # Use the sha / tag you want to point at | ||
hooks: | ||
- id: prettier | ||
args: [--print-width=120] | ||
types_or: [yaml, markdown, html, css, scss, javascript, json] | ||
additional_dependencies: | ||
- [email protected] | ||
|
||
- repo: https://github.com/psf/black.git | ||
rev: 24.3.0 | ||
hooks: | ||
- id: black | ||
files: (.*\.py)$ | ||
|
||
- repo: https://github.com/asottile/blacken-docs | ||
rev: 1.16.0 | ||
hooks: | ||
- id: blacken-docs | ||
args: [--line-length=120, --skip-errors] | ||
additional_dependencies: | ||
- black==24.3.0 | ||
|
||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.2.6 | ||
hooks: | ||
- id: codespell | ||
args: [-w] | ||
additional_dependencies: | ||
- tomli | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.3.4 | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --exit-non-zero-on-fix, --no-cache] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
[tool.isort] | ||
profile = "black" | ||
line_length = 120 | ||
extend_skip_glob = ["**/__init__.py"] | ||
|
||
|
||
[tool.black] | ||
line-length = 120 | ||
|
||
|
||
[tool.codespell] | ||
skip = '*.po,*.js,*.map,*.js.map,*.css.map,*.json' | ||
count = '' | ||
quiet-level = 3 | ||
ignore-words = ".github/code_spell_ignore.txt" | ||
|
||
|
||
[tool.ruff] | ||
# Exclude a variety of commonly ignored directories. | ||
exclude = [ | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".git-rewrite", | ||
".hg", | ||
".ipynb_checkpoints", | ||
".mypy_cache", | ||
".nox", | ||
".pants.d", | ||
".pyenv", | ||
".pytest_cache", | ||
".pytype", | ||
".ruff_cache", | ||
".svn", | ||
".tox", | ||
".venv", | ||
".vscode", | ||
"__pypackages__", | ||
"_build", | ||
"buck-out", | ||
"build", | ||
"dist", | ||
"node_modules", | ||
"site-packages", | ||
"venv", | ||
] | ||
|
||
# Same as Black. | ||
line-length = 120 | ||
indent-width = 4 | ||
|
||
# Assume Python 3.10 | ||
target-version = "py310" | ||
|
||
[tool.ruff.lint] | ||
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. | ||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or | ||
# McCabe complexity (`C901`) by default. | ||
select = ["E4", "E7", "E9", "F"] | ||
ignore = [ | ||
"E402", # Module level import not at top of file | ||
"E501", # Line too long (121 > 120 characters) | ||
"E721", # Do not compare types, use isinstance() | ||
"E722", # Do not use bare except | ||
"E731", # Do not assign a lambda expression, use a def | ||
"E741", # Do not use variables named ‘l’, ‘O’, or ‘I’ | ||
"F401", # {name} imported but unused | ||
"F403", # from {name} import * used; unable to detect undefined names | ||
"F405", # {name} may be undefined, or defined from star imports | ||
"F841", # Local variable is assigned to but never used{name} | ||
] | ||
|
||
# Allow fix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
# Allow unused variables when underscore-prefixed. | ||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
ignore-init-module-imports = true | ||
|
||
[tool.ruff.format] | ||
# Like Black, use double quotes for strings. | ||
quote-style = "double" | ||
|
||
# Like Black, indent with spaces, rather than tabs. | ||
indent-style = "space" | ||
|
||
# Like Black, respect magic trailing commas. | ||
skip-magic-trailing-comma = false | ||
|
||
# Like Black, automatically detect the appropriate line ending. | ||
line-ending = "auto" | ||
|
||
# Enable auto-formatting of code examples in docstrings. Markdown, | ||
# reStructuredText code/literal blocks and doctests are all supported. | ||
# | ||
# This is currently disabled by default, but it is planned for this | ||
# to be opt-out in the future. | ||
docstring-code-format = false | ||
|
||
# Set the line length limit used when formatting code snippets in | ||
# docstrings. | ||
# | ||
# This only has an effect when the `docstring-code-format` setting is | ||
# enabled. | ||
docstring-code-line-length = "dynamic" |