-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
103 lines (92 loc) · 3.23 KB
/
.pre-commit-config.yaml
File metadata and controls
103 lines (92 loc) · 3.23 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
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
99
100
101
102
103
# Pre-commit configuration
# https://pre-commit.com/
default_language_version:
python: python3.9
default_stages: [pre-commit]
repos:
# Ruff - 代码检查和格式化
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
types: [python]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types: [python]
# Pre-commit hooks for general checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace # 删除行尾空格
- id: end-of-file-fixer # 文件末尾添加换行
- id: mixed-line-ending # 强制统一行尾符为 LF
args: ['--fix=lf']
exclude: ^(\.bat|\.cmd|\.ps1)$
- id: check-yaml # 检查 YAML 语法
- id: check-toml # 检查 TOML 语法
- id: check-added-large-files # 防止大文件提交
args: ['--maxkb=1000']
- id: check-merge-conflict # 检查合并冲突标记
- id: check-case-conflict # 检查大小写冲突
- id: check-docstring-first # 检查 docstring 是否在代码前
# Mypy - 静态类型检查
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
types: [python]
additional_dependencies:
- types-setuptools
- types-requests>=2.31.0
- types-tqdm>=4.66.0
exclude: ^remark\.py$
# Local hooks - pre-commit 和 pre-push 阶段
- repo: local
hooks:
- id: run-tests
name: Run tests
entry: pytest -v -m "not slow" --cov=remark --cov-report=term-missing
language: system
types: [python]
stages: [pre-commit, pre-push]
pass_filenames: false
- id: build-exe
name: Build exe (Windows only)
entry: bash -c 'set -e; if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then pyinstaller remark.spec --clean && ./dist/windows-folder-remark.exe --help; else echo "Skip build on non-Windows"; fi'
language: system
files: '^(.*\.py|.*\.spec)$'
stages: [pre-push]
pass_filenames: false
# i18n 相关检查
- id: extract-translations
name: Extract i18n messages
entry: bash -c 'pybabel extract -k "_" -k "gettext" -k "ngettext" -o messages.pot remark/ && echo "Translations extracted successfully"'
language: system
types: [python]
stages: [pre-commit]
pass_filenames: false
require_serial: true
- id: check-i18n-completeness
name: Check i18n completeness
entry: bash -c 'pybabel update -i messages.pot -d locale && python scripts/check_i18n.py locale/*/LC_MESSAGES/messages.po'
language: system
types: [python]
stages: [pre-commit]
pass_filenames: false
- id: check-po-files
name: Check PO files with polint
entry: bash -c 'if compgen -G "locale/*/LC_MESSAGES/*.po" > /dev/null; then polint locale/*/LC_MESSAGES/*.po || true; fi'
language: system
types: [po]
stages: [pre-commit]
# 全局排除
exclude: |
^(?:
\.venv/|
\.git/|
\.mypy_cache/|
__pycache__/|
build/|
dist/|
*.egg-info/
)