-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
189 lines (169 loc) · 6.53 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
189 lines (169 loc) · 6.53 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
# Ensures no trailing whitespace in files, which can cause
# merge conflicts and makes diffs harder to read.
- id: trailing-whitespace
# Ensures each file ends with a newline, which is a POSIX standard
# for text files and can prevent errors with certain parsers.
- id: end-of-file-fixer
exclude: media/coverage-badge.svg
# Validates YAML file syntax, which is helpful since YAML is
# whitespace-sensitive and prone to syntax errors.
- id: check-yaml
# Checks the syntax of TOML files, ensuring the correctness of
# `pyproject.toml` or other configuration files in TOML format.
- id: check-toml
# Detects private keys accidentally committed to the repository,
# which helps prevent sensitive information from being exposed.
- id: detect-private-key
- repo: https://github.com/python-poetry/poetry
rev: "2.4.1"
hooks:
# Verifies that the `pyproject.toml` file is valid and follows Poetry's
# expected syntax, which ensures consistent dependency management.
- id: poetry-check
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v0.1.0"
hooks:
# Formats the `pyproject.toml` file to follow a consistent structure
# and style, making it easier to read and maintain.
- id: pyproject-fmt
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
# Detects and corrects common typos in the codebase, improving
# readability and reducing minor mistakes.
# Skip patterns are configured in [tool.codespell] in pyproject.toml
# so that `codespell` can be invoked directly with the same exclusions.
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/executablebooks/mdformat
rev: 1.0.0
hooks:
# Formats Markdown files to ensure a consistent style,
# making the documentation easier to read and maintain.
- id: mdformat
additional_dependencies:
- mdformat-gfm
- repo: https://github.com/adrienverge/yamllint
rev: v1.38.0
hooks:
# Lints YAML files to enforce consistent formatting, which
# makes YAML easier to read and reduces syntax errors.
- id: yamllint
exclude: pre-commit-config.yaml
- repo: https://github.com/psf/black
rev: 26.5.1
hooks:
# Formats Python code to follow the Black code style,
# promoting consistency and readability across the codebase.
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: 1.20.0
hooks:
# Formats code blocks in Markdown and reStructuredText
# documentation files with Black's style, ensuring
# consistency in inline code snippets.
- id: blacken-docs
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.3
hooks:
# removes unused imports automatically
- id: autoflake
args:
- "--remove-all-unused-imports"
- "--in-place"
- "--ignore-init-module-imports"
- repo: https://github.com/PyCQA/isort
rev: 8.0.1
hooks:
# Sorts imports in Python files, making the code easier to
# navigate and reducing merge conflicts in import statements.
- id: isort
- repo: https://github.com/PyCQA/bandit
rev: 1.9.4
hooks:
# Scans Python code for common security issues, helping to identify
# and fix potential vulnerabilities in the codebase.
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.15.19"
hooks:
# A fast linter that checks for stylistic errors in Python code,
# helping maintain code quality and adherence to style guidelines.
- id: ruff-check
- repo: https://github.com/rhysd/actionlint
rev: v1.7.12
hooks:
# Lints GitHub Actions workflows, ensuring syntax correctness and
# reducing errors in continuous integration and automation configurations.
- id: actionlint-docker
- repo: https://github.com/citation-file-format/cffconvert
rev: b6045d78aac9e02b039703b030588d54d53262ac
hooks:
# Validates `CITATION.cff` files, ensuring proper citation metadata
# for the repository, which promotes good citation practices.
- id: validate-cff
- repo: https://github.com/jendrikseipp/vulture
rev: 'v2.16'
hooks:
# Detects unused code, helping identify dead code that can be removed
# to keep the codebase lean and maintainable.
- id: vulture
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
# Runs Black formatting on Jupyter notebooks, ensuring code cells
# adhere to the Black code style.
- id: nbqa-black
# Runs isort on Jupyter notebooks, sorting imports in code
# cells for consistency.
- id: nbqa-isort
args: ["--float-to-top"]
- repo: https://github.com/aristanetworks/j2lint
rev: v1.2.0
hooks:
# Lints Jinja2 templates, ensuring they follow best practices
- id: j2lint
- repo: local
hooks:
# Runs the Vale linting tool to check for spelling, grammar,
# and style errors in text files, improving the quality of documentation.
- id: vale.sh
name: vale.sh writing checks
entry: poetry run poe vale-checks
language: system
pass_filenames: false
# Generage code coverage data
- id: code-cov-gen
name: Generate code coverage data
language: system
entry: poetry run poe code-coverage-report
pass_filenames: false
always_run: true
# Run the Almanack hook locally, skipping the tests directory.
- id: almanack-check
name: almanack-check
entry: almanack check .
language: python
pass_filenames: false
args:
- "--exclude_paths=tests,src/book/_build,src/book/seed-bank/almanack-example/almanack-example.ipynb"
additional_dependencies: ["."]
- repo: https://github.com/Weird-Sheep-Labs/coverage-pre-commit
rev: 0.1.1
hooks:
# generate code coverage badge
- id: coverage-badge
args: ["-i", "coverage.xml", "-o", "media/coverage-badge.svg"]
# pkg_resources was removed in newer setuptools; genbadge still imports it.
additional_dependencies: ["setuptools<81"]