-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
47 lines (43 loc) · 1.72 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
47 lines (43 loc) · 1.72 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
46
47
repos:
# ===================== 基础必选钩子 =====================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # 稳定版本
hooks:
- id: trailing-whitespace # 移除行尾空格
- id: end-of-file-fixer # 确保文件以空行结尾
- id: check-yaml # 检查YAML语法
- id: check-ast # 检查Python AST语法
- id: check-added-large-files # 拦截大文件
args: ['--maxkb=1000'] # 调整大文件阈值为1000KB(适配AI项目小数据集)
- id: check-case-conflict # 检查文件名大小写冲突
- id: check-merge-conflict # 检查合并冲突标记
- id: debug-statements # 检查调试语句
# 整理import顺序:isort
- repo: https://github.com/PyCQA/isort
rev: 5.13.2 # 稳定版本
hooks:
- id: isort
args: ['--profile=black'] # 和black格式兼容
# 代码风格检查:ruff (替代flake8,性能更好)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
# 检测硬编码密钥:detect-secrets (暂时禁用,基线文件问题)
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.5.0 # 最新版本
# hooks:
# - id: detect-secrets
# args: ['--baseline', '.secrets.baseline'] # 基线文件(避免误报)
# exclude: |
# (?x)^(
# tests/.*|
# pyproject.toml
# )$
# 整理pyproject.toml:toml-sort
- repo: https://github.com/pappasam/toml-sort
rev: v0.24.2 # 最新版本
hooks:
- id: toml-sort
args: ['--in-place', 'pyproject.toml']