Skip to content

Commit 8d8efe9

Browse files
committed
Add a pre-commit configuration
As in Matplotlib, it tests flake8, codespell, and some whitespace. It also checks YAML linting and the YAML schema. Also, add an ignored word for codespell, and a schema for checking package YAML files. The latter confirms that: - all required keys are included - values are the right type, such as `keywords` being an array, not a string - the description ends with a period
1 parent 723f90d commit 8d8efe9

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

.pre-commit-config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ci:
2+
autofix_prs: false
3+
autoupdate_schedule: 'quarterly'
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.4.0
7+
hooks:
8+
- id: check-added-large-files
9+
- id: check-docstring-first
10+
- id: end-of-file-fixer
11+
exclude_types: [svg]
12+
- id: mixed-line-ending
13+
- id: name-tests-test
14+
args: ["--pytest-test-first"]
15+
- id: trailing-whitespace
16+
exclude_types: [svg]
17+
- repo: https://github.com/pycqa/flake8
18+
rev: 6.0.0
19+
hooks:
20+
- id: flake8
21+
additional_dependencies: [flake8-force]
22+
- repo: https://github.com/codespell-project/codespell
23+
rev: v2.2.4
24+
hooks:
25+
- id: codespell
26+
files: ^.*\.(py|c|cpp|h|m|md|rst|yml)$
27+
args: ["--ignore-words", "ci/codespell-ignore-words.txt"]
28+
- repo: https://github.com/adrienverge/yamllint
29+
rev: v1.30.0
30+
hooks:
31+
- id: yamllint
32+
- repo: https://github.com/python-jsonschema/check-jsonschema
33+
rev: 0.22.0
34+
hooks:
35+
- id: check-jsonschema
36+
files: ^packages/.*\.yml$
37+
args: ['--schemafile', 'package-schema.json']

ci/codespell-ignore-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nd

package-schema.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "http://matplotlib.org/mpl-third-party/schema.yml",
4+
"type": "object",
5+
"required": ["name", "repo", "section", "description"],
6+
"properties": {
7+
"name": {"type": "string"},
8+
"repo": {
9+
"type": "string",
10+
"pattern": "^[^/]+/[^/]+$"
11+
},
12+
"section": {"type": "string"},
13+
"description": {
14+
"type": "string",
15+
"pattern": "^.+\\.$"
16+
},
17+
18+
"badges": {
19+
"type": "array",
20+
"items": {"type": "string"},
21+
"uniqueItems": true
22+
},
23+
"conda_channel": {"type": "string"},
24+
"conda_package": {"type": "string"},
25+
"keywords": {
26+
"type": "array",
27+
"items": {"type": "string"},
28+
"uniqueItems": true
29+
},
30+
"pypi_name": {"type": "string"},
31+
"site": {"type": "string"}
32+
},
33+
"additionalProperties": false
34+
}

0 commit comments

Comments
 (0)