未验证 提交 b4a3cca1 编写于 作者: N Nyakku Shigure 提交者: GitHub

[CodeStyle] refine pre-commit-config.yaml (#47693)

* sort hooks

* add `name` for remove-tabs
上级 01bfe786
...@@ -10,14 +10,29 @@ exclude: | ...@@ -10,14 +10,29 @@ exclude: |
python/paddle/fluid/tests/unittests/mlu/.+ python/paddle/fluid/tests/unittests/mlu/.+
)$ )$
repos: repos:
# Common hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: sort-simple-yaml
files: (ops|backward|op_[a-z_]+)\.yaml$
- id: trailing-whitespace
files: (.*\.(py|bzl|md|rst|c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps|cmake|yaml|yml|hook)|BUILD|.*\.BUILD|WORKSPACE|CMakeLists\.txt)$
- repo: https://github.com/Lucas-C/pre-commit-hooks.git - repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.1.14 rev: v1.1.14
hooks: hooks:
- id: remove-crlf - id: remove-crlf
- id: remove-tabs - id: remove-tabs
name: Tabs remover (C++)
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$ files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$
args: [--whitespaces-count, '2'] args: [--whitespaces-count, '2']
- id: remove-tabs - id: remove-tabs
name: Tabs remover (Python)
files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
args: [--whitespaces-count, '4'] args: [--whitespaces-count, '4']
# Exclude the fluid directory but keep the fluid/tests directory. # Exclude the fluid directory but keep the fluid/tests directory.
...@@ -28,6 +43,18 @@ repos: ...@@ -28,6 +43,18 @@ repos:
python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py| python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py|
python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py
)$ )$
- repo: local
hooks:
- id: copyright_checker
name: copyright_checker
entry: python ./tools/codestyle/copyright.hook
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|xpu|kps|py|sh)$
exclude: |
(?x)^(
paddle/utils/.*
)$
# For Python files
- repo: https://github.com/psf/black.git - repo: https://github.com/psf/black.git
rev: 22.8.0 rev: 22.8.0
hooks: hooks:
...@@ -37,18 +64,25 @@ repos: ...@@ -37,18 +64,25 @@ repos:
rev: 4.0.1 rev: 4.0.1
hooks: hooks:
- id: flake8 - id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/PyCQA/autoflake
rev: v4.1.0 rev: v1.7.7
hooks: hooks:
- id: check-added-large-files - id: autoflake
- id: check-merge-conflict args:
- id: check-symlinks - --in-place
- id: detect-private-key - --remove-all-unused-imports
- id: end-of-file-fixer - --ignore-pass-after-docstring
- id: sort-simple-yaml - --ignore-init-module-imports
files: (ops|backward|op_[a-z_]+)\.yaml$ - --exclude=python/paddle/fluid/[!t]**,python/paddle/fluid/tra**
- id: trailing-whitespace - repo: local
files: (.*\.(py|bzl|md|rst|c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps|cmake|yaml|yml|hook)|BUILD|.*\.BUILD|WORKSPACE|CMakeLists\.txt)$ hooks:
- id: pylint-doc-string
name: pylint
description: Check python docstring style using docstring_checker.
entry: bash ./tools/codestyle/pylint_pre_commit.hook
language: system
files: \.(py)$
# For C++ files
- repo: local - repo: local
hooks: hooks:
- id: clang-format - id: clang-format
...@@ -69,25 +103,7 @@ repos: ...@@ -69,25 +103,7 @@ repos:
- --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps - --extensions=c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps
- --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens - --filter=-readability/fn_size,-build/include_what_you_use,-build/c++11,-whitespace/parens
- --quiet - --quiet
- repo: local # For CMake files
hooks:
- id: pylint-doc-string
name: pylint
description: Check python docstring style using docstring_checker.
entry: bash ./tools/codestyle/pylint_pre_commit.hook
language: system
files: \.(py)$
- repo: local
hooks:
- id: copyright_checker
name: copyright_checker
entry: python ./tools/codestyle/copyright.hook
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|xpu|kps|py|sh)$
exclude: |
(?x)^(
paddle/utils/.*
)$
- repo: local - repo: local
hooks: hooks:
- id: auto-generate-cmakelists - id: auto-generate-cmakelists
...@@ -105,20 +121,8 @@ repos: ...@@ -105,20 +121,8 @@ repos:
(?x)^( (?x)^(
paddle/fluid/operators/CMakeLists.txt paddle/fluid/operators/CMakeLists.txt
)$ )$
- repo: https://github.com/cmake-lint/cmake-lint - repo: https://github.com/cmake-lint/cmake-lint
rev: 1.4.2 rev: 1.4.2
hooks: hooks:
- id: cmakelint - id: cmakelint
args: [--config=./tools/codestyle/.cmakelintrc] args: [--config=./tools/codestyle/.cmakelintrc]
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --ignore-pass-after-docstring
- --ignore-init-module-imports
- --exclude=python/paddle/fluid/[!t]**,python/paddle/fluid/tra**
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册