|
1 | 1 | # To run all pre-commit checks, use: |
2 | 2 | # |
3 | | -# pre-commit run -a |
| 3 | +# uvx prek run -a |
4 | 4 | # |
5 | 5 | # To install pre-commit hooks that run every time you commit: |
6 | 6 | # |
7 | | -# pre-commit install |
| 7 | +# uv tool install prek |
| 8 | +# prek install |
8 | 9 | # |
9 | 10 |
|
10 | 11 | ci: |
11 | 12 | autoupdate_commit_msg: "⬆️🪝 update pre-commit hooks" |
12 | | - autofix_commit_msg: "🎨 pre-commit fixes" |
13 | 13 | autoupdate_schedule: quarterly |
| 14 | + autofix_commit_msg: "🎨 pre-commit fixes" |
14 | 15 | skip: [mypy] |
15 | 16 |
|
16 | 17 | repos: |
17 | | - # Standard hooks |
| 18 | + # Priority 0: Fast validation and independent fixers |
| 19 | + |
| 20 | + ## Standard hooks |
18 | 21 | - repo: https://github.com/pre-commit/pre-commit-hooks |
19 | 22 | rev: v6.0.0 |
20 | 23 | hooks: |
21 | | - - id: check-added-large-files |
22 | | - args: ["--maxkb=2048"] |
23 | | - - id: check-case-conflict |
24 | | - - id: check-vcs-permalinks |
25 | 24 | - id: check-merge-conflict |
26 | | - - id: check-symlinks |
27 | | - - id: check-json |
28 | | - - id: check-toml |
29 | | - - id: check-yaml |
30 | | - - id: debug-statements |
| 25 | + priority: 0 |
31 | 26 | - id: end-of-file-fixer |
32 | | - - id: mixed-line-ending |
| 27 | + priority: 1 |
33 | 28 | - id: trailing-whitespace |
| 29 | + priority: 1 |
34 | 30 |
|
35 | | - # Clean jupyter notebooks |
36 | | - - repo: https://github.com/srstevenson/nb-clean |
37 | | - rev: 4.0.1 |
| 31 | + ## Check the pyproject.toml file |
| 32 | + - repo: https://github.com/henryiii/validate-pyproject-schema-store |
| 33 | + rev: 2026.01.22 |
38 | 34 | hooks: |
39 | | - - id: nb-clean |
40 | | - args: |
41 | | - - --remove-empty-cells |
42 | | - - --preserve-cell-metadata |
43 | | - - raw_mimetype |
44 | | - - -- |
45 | | - |
46 | | - # Handling unwanted unicode characters |
47 | | - - repo: https://github.com/sirosen/texthooks |
48 | | - rev: 0.7.1 |
| 35 | + - id: validate-pyproject |
| 36 | + priority: 0 |
| 37 | + |
| 38 | + ## Check JSON schemata |
| 39 | + - repo: https://github.com/python-jsonschema/check-jsonschema |
| 40 | + rev: 0.36.0 |
| 41 | + hooks: |
| 42 | + - id: check-github-workflows |
| 43 | + priority: 0 |
| 44 | + - id: check-readthedocs |
| 45 | + priority: 0 |
| 46 | + |
| 47 | + ## Catch common capitalization mistakes |
| 48 | + - repo: local |
49 | 49 | hooks: |
50 | | - - id: fix-ligatures |
51 | | - - id: fix-smartquotes |
| 50 | + - id: disallow-caps |
| 51 | + name: Disallow improper capitalization |
| 52 | + language: pygrep |
| 53 | + entry: Nanobind|Numpy|Cmake|CCache|Github|PyTest|Mqt|Tum|MQTopt|MQTref |
| 54 | + exclude: .pre-commit-config.yaml |
| 55 | + priority: 0 |
52 | 56 |
|
53 | | - # Check for common mistakes |
54 | | - - repo: https://github.com/pre-commit/pygrep-hooks |
55 | | - rev: v1.10.0 |
| 57 | + ## Check for spelling |
| 58 | + - repo: https://github.com/adhtruong/mirrors-typos |
| 59 | + rev: v1.42.1 |
56 | 60 | hooks: |
57 | | - - id: rst-backticks |
58 | | - - id: rst-directive-colons |
59 | | - - id: rst-inline-touching-normal |
| 61 | + - id: typos |
| 62 | + priority: 0 |
60 | 63 |
|
61 | | - # Check for license headers |
| 64 | + ## Check best practices for scientific Python code |
| 65 | + - repo: https://github.com/scientific-python/cookie |
| 66 | + rev: 2025.11.21 |
| 67 | + hooks: |
| 68 | + - id: sp-repo-review |
| 69 | + additional_dependencies: ["repo-review[cli]"] |
| 70 | + priority: 0 |
| 71 | + |
| 72 | + ## Check for license headers |
62 | 73 | - repo: https://github.com/emzeat/mz-lictools |
63 | 74 | rev: v2.9.0 |
64 | 75 | hooks: |
65 | 76 | - id: license-tools |
| 77 | + priority: 0 |
66 | 78 |
|
67 | | - # Ensure uv lock file is up-to-date |
| 79 | + ## Ensure uv lock file is up-to-date |
68 | 80 | - repo: https://github.com/astral-sh/uv-pre-commit |
69 | 81 | rev: 0.9.26 |
70 | 82 | hooks: |
71 | 83 | - id: uv-lock |
| 84 | + priority: 0 |
72 | 85 |
|
73 | | - # Python linting using ruff |
74 | | - - repo: https://github.com/astral-sh/ruff-pre-commit |
75 | | - rev: v0.14.14 |
| 86 | + ## Tidy up BibTeX files |
| 87 | + - repo: https://github.com/FlamingTempura/bibtex-tidy |
| 88 | + rev: v1.14.0 |
76 | 89 | hooks: |
77 | | - - id: ruff-check |
78 | | - - id: ruff-format |
| 90 | + - id: bibtex-tidy |
| 91 | + args: |
| 92 | + [ |
| 93 | + "--align=20", |
| 94 | + "--curly", |
| 95 | + "--months", |
| 96 | + "--blank-lines", |
| 97 | + "--sort", |
| 98 | + "--strip-enclosing-braces", |
| 99 | + "--sort-fields", |
| 100 | + "--trailing-commas", |
| 101 | + "--remove-empty-fields", |
| 102 | + ] |
| 103 | + priority: 0 |
79 | 104 |
|
80 | | - # Static type checking using mypy |
81 | | - - repo: https://github.com/pre-commit/mirrors-mypy |
82 | | - rev: v1.19.1 |
83 | | - hooks: |
84 | | - - id: mypy |
85 | | - files: ^(python/mqt|test/python) |
86 | | - args: [] |
87 | | - additional_dependencies: |
88 | | - - pandas-stubs |
89 | | - - pytest |
90 | | - - scipy-stubs |
91 | | - - types-networkx |
| 105 | + # Priority 1: Second-pass fixers |
92 | 106 |
|
93 | | - # Also run Black on examples in the documentation |
94 | | - - repo: https://github.com/adamchainz/blacken-docs |
95 | | - rev: 1.20.0 |
96 | | - hooks: |
97 | | - - id: blacken-docs |
98 | | - additional_dependencies: [black==25.*] |
99 | | - |
100 | | - # Clang-format the C++ part of the code base automatically |
| 107 | + ## Clang-format the C++ part of the code base automatically |
101 | 108 | - repo: https://github.com/pre-commit/mirrors-clang-format |
102 | 109 | rev: v21.1.8 |
103 | 110 | hooks: |
104 | 111 | - id: clang-format |
105 | 112 | types_or: [c++, c, cuda] |
| 113 | + priority: 1 |
106 | 114 |
|
107 | | - # CMake format and lint the CMakeLists.txt files |
| 115 | + ## CMake format and lint the CMakeLists.txt files |
108 | 116 | - repo: https://github.com/cheshirekow/cmake-format-precommit |
109 | 117 | rev: v0.6.13 |
110 | 118 | hooks: |
111 | 119 | - id: cmake-format |
112 | 120 | additional_dependencies: [pyyaml] |
113 | 121 | types: [file] |
114 | 122 | files: (\.cmake|CMakeLists.txt)(.in)?$ |
| 123 | + priority: 1 |
115 | 124 |
|
116 | | - # Format configuration files with prettier |
| 125 | + ## Format configuration files with prettier |
117 | 126 | - repo: https://github.com/rbubley/mirrors-prettier |
118 | 127 | rev: v3.8.1 |
119 | 128 | hooks: |
120 | 129 | - id: prettier |
121 | 130 | types_or: [yaml, markdown, html, css, scss, javascript, json] |
| 131 | + priority: 1 |
122 | 132 |
|
123 | | - # Check for spelling |
124 | | - - repo: https://github.com/adhtruong/mirrors-typos |
125 | | - rev: v1.42.1 |
126 | | - hooks: |
127 | | - - id: typos |
128 | | - |
129 | | - # Catch common capitalization mistakes |
130 | | - - repo: local |
131 | | - hooks: |
132 | | - - id: disallow-caps |
133 | | - name: Disallow improper capitalization |
134 | | - language: pygrep |
135 | | - entry: PyBind|Numpy|Cmake|CCache|Github|PyTest|Mqt|Tum |
136 | | - exclude: .pre-commit-config.yaml |
137 | | - |
138 | | - # Check best practices for scientific Python code |
139 | | - - repo: https://github.com/scientific-python/cookie |
140 | | - rev: 2025.11.21 |
| 133 | + ## Python linting using ruff |
| 134 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 135 | + rev: v0.14.14 |
141 | 136 | hooks: |
142 | | - - id: sp-repo-review |
143 | | - additional_dependencies: ["repo-review[cli]"] |
| 137 | + - id: ruff-format |
| 138 | + priority: 1 |
| 139 | + - id: ruff-check |
| 140 | + require_serial: true |
| 141 | + priority: 2 |
144 | 142 |
|
145 | | - # Check JSON schemata |
146 | | - - repo: https://github.com/python-jsonschema/check-jsonschema |
147 | | - rev: 0.36.0 |
148 | | - hooks: |
149 | | - - id: check-dependabot |
150 | | - - id: check-github-workflows |
151 | | - - id: check-readthedocs |
| 143 | + # Priority 2+: Final checks and fixers |
152 | 144 |
|
153 | | - # Check the pyproject.toml file |
154 | | - - repo: https://github.com/henryiii/validate-pyproject-schema-store |
155 | | - rev: 2026.01.22 |
| 145 | + ## Also run Black on examples in the documentation (needs to run after ruff format) |
| 146 | + - repo: https://github.com/adamchainz/blacken-docs |
| 147 | + rev: 1.20.0 |
156 | 148 | hooks: |
157 | | - - id: validate-pyproject |
| 149 | + - id: blacken-docs |
| 150 | + language: python |
| 151 | + additional_dependencies: [black==26.*] |
| 152 | + priority: 2 |
158 | 153 |
|
159 | | - # Tidy up BibTeX files |
160 | | - - repo: https://github.com/FlamingTempura/bibtex-tidy |
161 | | - rev: v1.14.0 |
| 154 | + ## Static type checking using mypy (needs to run after lockfile update/ruff format, and ruff lint) |
| 155 | + - repo: https://github.com/pre-commit/mirrors-mypy |
| 156 | + rev: v1.19.1 |
162 | 157 | hooks: |
163 | | - - id: bibtex-tidy |
164 | | - args: |
165 | | - [ |
166 | | - "--align=20", |
167 | | - "--curly", |
168 | | - "--months", |
169 | | - "--blank-lines", |
170 | | - "--sort", |
171 | | - "--strip-enclosing-braces", |
172 | | - "--sort-fields", |
173 | | - "--trailing-commas", |
174 | | - "--remove-empty-fields", |
175 | | - ] |
| 158 | + - id: mypy |
| 159 | + files: ^(python/mqt|test/python) |
| 160 | + args: [] |
| 161 | + additional_dependencies: |
| 162 | + - pandas-stubs |
| 163 | + - pytest |
| 164 | + - scipy-stubs |
| 165 | + - types-networkx |
0 commit comments