-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.pre-commit-config.yaml
137 lines (136 loc) · 4.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
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 to main/master
- id: no-commit-to-branch
# Sort spell check custom dictionary
- id: file-contents-sorter
files: ^.cspell/(custom_misc|library_terms|people).txt$
args:
- --ignore-case
- --unique
- 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)^(
examples/.+/.+.(gif|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-emit-project
--extra doc
--output-file requirements-doc.txt
pass_filenames: false
files: ^uv\.lock$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
# No tabs, only spaces
- id: forbid-tabs
exclude: documentation/make.bat|documentation/Makefile
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.0
hooks:
# Run a spellcheck (words pulled from cspell.config.yaml)
- id: cspell
stages:
- pre-commit
- pre-merge-commit
- commit-msg
exclude_types:
- batch
- gitignore
- makefile
- pylintrc
- svg
exclude: requirements(-.*)?.txt|.cspell/.*
# Python specific Hooks
- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
# Ensure that necessary package information is provided
- id: pyroma
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
# Enforce that type annotations are used instead of type comments
- id: python-use-type-annotations
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Abort if ruff linter fails as there is some duplication of functionality with
# the slow pylint hook
fail_fast: true
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
# Python static analysis tool
- id: pylint
name: pylint
entry: pylint
language: system
require_serial: true # ensure only one Pylint process is used
types:
- python
args:
- "-rn" # Only display messages
- "-sn" # Don't display the score
- "--rcfile=.pylintrc" # pylint configuration file
exclude: "documentation/source/snippets"
- 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