|
1 | | -# Pre-commit hooks for CABiNet project |
2 | | -# Note: pre-commit will ignore anything that is already ignored by Git. |
| 1 | +# Pre-commit hooks configuration |
| 2 | +# See https://pre-commit.com for more information |
3 | 3 |
|
4 | 4 | default_language_version: |
5 | | - python: python3.10 |
| 5 | + python: python3 |
6 | 6 |
|
7 | 7 | repos: |
8 | | - # Python code formatting |
9 | | - - repo: https://github.com/psf/black |
10 | | - rev: 25.1.0 |
| 8 | + # ---------- BASIC SANITY ---------- |
| 9 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 10 | + rev: v6.0.0 |
11 | 11 | hooks: |
12 | | - - id: black |
13 | | - language_version: python3 |
14 | | - args: [--line-length=100] |
15 | | - exclude: ^(legacy/|.*\.ipynb) |
| 12 | + - id: trailing-whitespace |
| 13 | + - id: end-of-file-fixer |
| 14 | + - id: check-yaml |
| 15 | + - id: check-toml |
| 16 | + - id: check-json |
| 17 | + - id: check-added-large-files |
| 18 | + args: [--maxkb=5000] |
| 19 | + - id: check-ast |
| 20 | + - id: debug-statements |
| 21 | + - id: check-merge-conflict |
| 22 | + - id: detect-private-key |
16 | 23 |
|
17 | | - # Import sorting |
18 | | - - repo: https://github.com/pycqa/isort |
19 | | - rev: 5.13.2 |
| 24 | + # ---------- PYTHON FORMAT ---------- |
| 25 | + - repo: https://github.com/psf/black |
| 26 | + rev: 25.12.0 |
20 | 27 | hooks: |
21 | | - - id: isort |
22 | | - language_version: python3 |
23 | | - args: [--profile=black, --line-length=100] |
24 | | - exclude: ^(legacy/|.*\.ipynb) |
| 28 | + - id: black |
| 29 | + args: [--line-length=88] |
25 | 30 |
|
26 | | - # Linting |
27 | | - - repo: https://github.com/pycqa/flake8 |
28 | | - rev: 7.3.0 |
| 31 | + # ---------- PYTHON LINT (NO FIX) ---------- |
| 32 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 33 | + rev: v0.14.10 |
29 | 34 | hooks: |
30 | | - - id: flake8 |
31 | | - language_version: python3 |
32 | | - additional_dependencies: [ |
33 | | - "flake8-docstrings", |
34 | | - "flake8-bugbear", |
35 | | - "flake8-comprehensions", |
36 | | - "pep8-naming", |
37 | | - ] |
38 | | - args: [--max-line-length=100, --extend-ignore=E203,W503] |
39 | | - exclude: ^(legacy/|tests/|.*\.ipynb) |
| 35 | + - id: ruff |
| 36 | + args: [--fix] |
| 37 | + types_or: [python, pyi] |
40 | 38 |
|
41 | | - # Type checking |
| 39 | + # ---------- TYPES ---------- |
42 | 40 | - repo: https://github.com/pre-commit/mirrors-mypy |
43 | | - rev: v1.14.0 |
| 41 | + rev: v1.19.1 |
44 | 42 | hooks: |
45 | 43 | - id: mypy |
46 | | - language_version: python3 |
47 | | - additional_dependencies: [types-all] |
48 | 44 | args: [--ignore-missing-imports, --check-untyped-defs] |
49 | | - exclude: ^(tests/|legacy/|.*\.ipynb) |
| 45 | + additional_dependencies: |
| 46 | + - types-PyYAML |
| 47 | + - types-requests |
| 48 | + files: ^src/ |
50 | 49 |
|
51 | | - # Security checks |
| 50 | + # ---------- SECURITY ---------- |
52 | 51 | - repo: https://github.com/PyCQA/bandit |
53 | | - rev: 1.8.0 |
| 52 | + rev: 1.9.2 |
54 | 53 | hooks: |
55 | 54 | - id: bandit |
56 | | - args: [-ll, -r, src/] |
57 | | - exclude: ^(tests/|legacy/) |
| 55 | + args: [-c, pyproject.toml, -r, src/] |
| 56 | + additional_dependencies: ["bandit[toml]"] |
58 | 57 |
|
59 | | - # Standard pre-commit hooks |
60 | | - - repo: https://github.com/pre-commit/pre-commit-hooks |
61 | | - rev: v5.0.0 |
62 | | - hooks: |
63 | | - - id: check-added-large-files |
64 | | - args: [--maxkb=1000] # Increased for model weights |
65 | | - - id: check-ast # Validate Python syntax |
66 | | - - id: check-builtin-literals # Require literal syntax |
67 | | - - id: check-case-conflict # Check for files with case conflicts |
68 | | - - id: check-docstring-first # Ensure docstring before code |
69 | | - - id: check-executables-have-shebangs |
70 | | - - id: check-json |
71 | | - - id: check-merge-conflict |
72 | | - - id: check-symlinks |
73 | | - - id: check-toml |
74 | | - - id: check-yaml |
75 | | - args: [--unsafe] # Allow custom YAML tags |
76 | | - - id: debug-statements # Check for debugger imports |
77 | | - - id: detect-private-key # Detect private keys |
78 | | - - id: end-of-file-fixer # Ensure files end with newline |
79 | | - - id: mixed-line-ending # Fix mixed line endings |
80 | | - args: [--fix=lf] |
81 | | - - id: trailing-whitespace # Remove trailing whitespace |
82 | | - args: [--markdown-linebreak-ext=md] |
83 | | - |
84 | | - # Docstring formatting |
85 | | - - repo: https://github.com/PyCQA/docformatter |
86 | | - rev: v1.7.7 |
87 | | - hooks: |
88 | | - - id: docformatter |
89 | | - args: [ |
90 | | - --in-place, |
91 | | - --wrap-summaries=100, |
92 | | - --wrap-descriptions=100, |
93 | | - --make-summary-multi-line, |
94 | | - ] |
95 | | - exclude: ^(legacy/|.*\.ipynb) |
96 | | - |
97 | | - # Upgrade Python syntax |
98 | | - - repo: https://github.com/asottile/pyupgrade |
99 | | - rev: v3.19.1 |
100 | | - hooks: |
101 | | - - id: pyupgrade |
102 | | - args: [--py38-plus] |
103 | | - exclude: ^(legacy/|.*\.ipynb) |
104 | | - |
105 | | - # YAML/JSON/TOML formatting |
| 58 | + # ---------- NON-PYTHON FORMAT ---------- |
106 | 59 | - repo: https://github.com/pre-commit/mirrors-prettier |
107 | 60 | rev: v4.0.0-alpha.8 |
108 | 61 | hooks: |
109 | 62 | - id: prettier |
110 | | - types_or: [yaml, json, toml, markdown] |
111 | | - exclude: ^(legacy/) |
| 63 | + types_or: [yaml, markdown, json] |
112 | 64 |
|
113 | | - # Jupyter notebook cleaning (optional) |
114 | | - - repo: https://github.com/kynan/nbstripout |
115 | | - rev: 0.8.1 |
| 65 | + # ---------- COMMIT MSG ---------- |
| 66 | + - repo: https://github.com/compilerla/conventional-pre-commit |
| 67 | + rev: v4.3.0 |
116 | 68 | hooks: |
117 | | - - id: nbstripout |
118 | | - description: Strip output from Jupyter notebooks |
119 | | - |
120 | | - # Check for TODO/FIXME comments (warning only) |
121 | | - - repo: https://github.com/pre-commit/mirrors-pylint |
122 | | - rev: v2.7.4 |
123 | | - hooks: |
124 | | - - id: pylint |
125 | | - args: [ |
126 | | - --disable=all, |
127 | | - --enable=fixme, |
128 | | - --notes=TODO,FIXME,XXX, |
129 | | - ] |
130 | | - exclude: ^(tests/|legacy/) |
131 | | - stages: [manual] # Only run when explicitly called |
132 | | - |
133 | | -# Configuration for specific hooks |
134 | | -ci: |
135 | | - autofix_commit_msg: | |
136 | | - [pre-commit.ci] auto fixes from pre-commit hooks |
137 | | - autofix_prs: true |
138 | | - autoupdate_branch: '' |
139 | | - autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' |
140 | | - autoupdate_schedule: weekly |
141 | | - skip: [pylint] # Skip slow hooks in CI |
142 | | - submodules: false |
| 69 | + - id: conventional-pre-commit |
| 70 | + stages: [commit-msg] |
0 commit comments