-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
98 lines (90 loc) · 2.78 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
exclude: '^.*\.(md|MD|xml|ini|cfg|txt)$|^\.idea/'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
# 检查YAML文件是否格式正确
- id: check-json
# 检查JSON文件是否格式正确
- id: trailing-whitespace
# 删除行尾空格
- id: check-added-large-files
# 检查是否有大文件被错误地添加到git
- id: end-of-file-fixer
# 确保文件以一个空行结尾
- id: mixed-line-ending
# 统一文件的行结束符(例如,将CRLF转换为LF)
args: [ "--fix=lf" ]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
files: \.(py|sh|rst|yml|yaml)$
args: [--write-changes]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
# 对Python的import语句进行排序和格式化
args:
[
"--profile",
"black",
"--multi-line=3",
"--trailing-comma",
"--force-grid-wrap=0",
"--use-parentheses",
"--line-width=88",
]
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
# 移除未使用的导入和变量
args:
[
"--in-place",
"--remove-all-unused-imports",
"--ignore-init-module-imports",
]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
# 将Python代码升级到新版本的Python语法
args: [ "--py310-plus" ]
- repo: https://github.com/psf/black
rev: "24.10.0"
hooks:
- id: black
# 自动格式化Python代码,符合PEP 8风格指南
args: [--line-length=88]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.0
hooks:
- id: commitizen
# 确保commit信息遵循Conventional Commits标准
stages: [ commit-msg ]
- repo: 'https://github.com/PyCQA/flake8'
rev: 7.1.1
hooks:
- id: flake8
args:
- '--max-line-length=88'
- '--ignore=E203,W503,F401'
language: python
types: [ python ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args: [ --ignore-missing-imports,--disallow-untyped-defs, --show-error-codes ]
# additional_dependencies: [ types-requests, types-setuptools ] # 如果需要额外的类型存根
ci:
# Settings for the https://pre-commit.ci/ continuous integration service
autofix_prs: True
# Default message is more verbose
autoupdate_commit_msg: '[pre-commit.ci] autoupdate'
# Default is weekly
autoupdate_schedule: monthly