-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
45 lines (41 loc) · 1.8 KB
/
.pre-commit-config.yaml
File metadata and controls
45 lines (41 loc) · 1.8 KB
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
# Pre-commit hooks configuration
# 如果不想使用 pre-commit hooks,可以运行: pre-commit uninstall
# 或者在提交时跳过检查: git commit --no-verify
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace # 移除行尾空格
- id: end-of-file-fixer # 确保文件以换行符结尾
- id: check-yaml # 检查YAML语法
args: ['--unsafe'] # 允许自定义标签
- id: check-added-large-files # 检查大文件
args: ['--maxkb=10000'] # 限制10MB
- id: check-merge-conflict # 检查合并冲突标记
- id: debug-statements # 检查调试语句
- id: check-json # 检查JSON语法
- id: check-toml # 检查TOML语法
- id: check-xml # 检查XML语法
- id: mixed-line-ending # 检查行结束符
- id: check-case-conflict # 检查文件名大小写冲突
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
hooks:
- id: ruff # Python代码检查
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi, jupyter]
- id: ruff-format # Python代码格式化
types_or: [python, pyi, jupyter]
# 可选: 添加类型检查 (如需要可取消注释)
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.8.0
# hooks:
# - id: mypy
# additional_dependencies: [types-all]
# args: [--ignore-missing-imports]
# 可选: 安全检查 (如需要可取消注释)
# - repo: https://github.com/PyCQA/bandit
# rev: '1.7.5'
# hooks:
# - id: bandit
# args: ['-r', 'src/', '-f', 'json', '-o', 'bandit-report.json']