-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
163 lines (163 loc) · 5.25 KB
/
.pre-commit-config.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
default_install_hook_types:
- pre-commit
- pre-merge-commit
- commit-msg
default_stages:
- pre-commit
- pre-merge-commit
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# Reject commits that add large files (coverage.xml, for example)
# Consider adjusting kB limit
- id: check-added-large-files
args:
- --enforce-all
- --maxkb=5000
# Check valid Python syntax
- id: check-ast
# Require literal syntax when initializing empty or zero python builtin types
- id: check-builtin-literals
# Check for files that would conflict in case-insensitive filesystems
- id: check-case-conflict
# Check for a common error of defining a docstring after code
- id: check-docstring-first
# Check for files that contain merge conflict strings
- id: check-merge-conflict
# Check TOML files for parsable syntax
- id: check-toml
# Check YAML files for parsable syntax
- id: check-yaml
# Files must end in a single newline
- id: end-of-file-fixer
# Remove whitespace at the end of lines
- id: trailing-whitespace
# Prevent commit directly to main
- id: no-commit-to-branch
args: [-b, main]
# Sort spell check custom dictionary
- id: file-contents-sorter
files: ^\.cspell/.+\.txt$
args:
- --ignore-case
- --unique
fail_fast: true
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
# Prevent common mistakes of `assert mck.not_called()`,
# `assert mck.called_once_with(...)` and `mck.assert_called`
- id: python-check-mock-methods
# Check for the deprecated `.warn()` method of Python loggers
- id: python-no-log-warn
# Enforce that type annotations are used instead of type comments
- id: python-use-type-annotations
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
# No tabs, only spaces
- id: forbid-tabs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.2
hooks:
# Run the formatter.
- id: ruff-format
types_or: [ python, jupyter ]
fail_fast: true
# Run the linter.
- id: ruff
types_or: [ python, jupyter ]
args: [--fix]
# Abort if ruff linter fails as there is some duplication of functionality with
# the slow pylint hook
fail_fast: true
- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
# Ensure that necessary package information is provided
- id: pyroma
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.3
hooks:
# Run a spellcheck (words pulled from cspell.config.yaml)
- id: cspell
stages:
- pre-commit
- pre-merge-commit
- commit-msg
exclude: |
(?x)^(
.gitignore|
.*.properties|
requirements.txt|
requirements-docs.txt|
.pylintrc|
LICENSE.md
)$
- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
hooks:
- id: nbstripout
args:
- --drop-empty-cells
- "--extra-keys=metadata.kernelspec cell.metadata.vscode metadata.language_info.version"
- --keep-id
- repo: local
hooks:
# Check files are valid UTF-8
- id: require-utf8
name: Check file encoding
description: Ensure file is valid UTF-8
entry: python pre_commit_hooks/require_utf8.py
language: python
exclude:
(?x)^(
docs/source/_static/.+.png
)$
# Keep requirements-docs.txt in sync with uv.lock
- id: check-requirements-docs
name: Keep requirements-docs.txt in sync with uv.lock
language: system
entry: >
uv export
--frozen
--quiet
--format requirements-txt
--no-hashes
--no-dev
--no-editable
--extra doc
--output-file requirements-docs.txt
pass_filenames: false
files: ^uv\.lock$
- id: check-copyright
name: Check for copyright notice
description: Ensure a copyright notice is present at the top of each Python file
entry: python pre_commit_hooks/check_copyright.py
types: [ python ]
language: python
# require_utf8 is excluded as it's licensed under the Apache license, so has a different header
exclude: |
(?x)^(
pre_commit_hooks/require_utf8.py
)$
- id: markdown-cells
name: forbid markdown cells
description: Forbid any Markdown cell in a Jupyter notebook
types: [jupyter]
entry: python pre_commit_hooks/markdown_cells.py
language: python
additional_dependencies: ["nbformat"]
- id: pylint
name: pylint
description: Run Pylint static analysis
entry: pylint
language: system
types:
- python
args:
- "-rn" # Only display messages
- "-sn" # Don't display the score
- "--rcfile=.pylintrc" # pylint configuration file
exclude: "documentation/source/snippets"