This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.pre-commit-config.yaml
105 lines (105 loc) · 3.39 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
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
# Note that fieldextra namelists requires an empty newline at the end of the file
# therefore we don't correct this here
exclude: ^tests/test_idpi/fieldextra_templates/.*
- id: trailing-whitespace
- repo: local
hooks:
- id: forbidden-files-copier-rej
name: find copier rejection files
language: fail
entry: "Found copier update rejection file(s): review and remove them"
files: "\\.rej$"
- id: forbidden-files-git-orig
name: find git merge backup files
language: fail
entry: "Found git merge backup file(s): review and remove them"
files: "\\.orig$"
- repo: local
hooks:
- id: rstcheck
name: rstcheck
description: Check REST files for correctness
language: system
entry: rstcheck
types: [rst]
- repo: local
hooks:
- id: codespell
name: codespell
description: Check for spelling errors
language: system
entry: codespell
- repo: local
hooks:
- id: black
name: black
description: Format Python code
language: system
entry: black
types_or: [python, pyi]
- repo: local
hooks:
- id: isort
name: isort
description: Group and sort Python imports
language: system
entry: isort
types_or: [python, pyi, cython]
- repo: local
hooks:
- id: pydocstyle
name: pydocstyle
description: Check docstrings in Python code for compliance with conventions
language: system
entry: pydocstyle
types: [python]
files: ^src/
# SR It would be handy to abort if one linter fails b/c the same error often
# SR triggers multiple linters. That way, if flake8 fails, pylint and mypy
# SR (which in large code bases can take some time to run) could be skipped
# SR before fixing the error. Unfortunately, pre-commit only provides the global
# SR option fail_fast, which would abort even after the small fixers and
# SR formatters changed something. A potential solution could be to write a
# SR small bash script run-linters.sh that runs flake8, pylint and run-mypy.sh
# SR in that order and aborts on error.
# TODO: There is significant work involved in getting pylint going. This can be its separate task
# - repo: local
# hooks:
# - id: pylint
# name: pylint
# description: Check Python code for correctness, consistency and adherence to best practices
# language: system
# entry: pylint
# types: [python]
- repo: local
hooks:
- id: flake8
name: flake8
description: Check Python code for correctness, consistency and adherence to best practices
language: system
entry: flake8
types: [python]
- repo: local
hooks:
- id: mypy
name: mypy
description: Perform static type analysis of Python code
language: system
entry: bash tools/run-mypy.sh
require_serial: true
pass_filenames: false
verbose: true
types: [python]
files: ^(src|tests)/