.pre-commit-config.yaml 3.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# To use:
#
#     pre-commit run -a
#
# Or:
#
#     pre-commit install  # (runs every time you commit in git)
#
# To update this file:
#
#     pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

15
repos:
16
# Standard hooks
17
- repo: https://github.com/pre-commit/pre-commit-hooks
18
  rev: v4.1.0
19
20
21
  hooks:
  - id: check-added-large-files
  - id: check-case-conflict
22
  - id: check-docstring-first
23
24
  - id: check-merge-conflict
  - id: check-symlinks
25
  - id: check-toml
26
27
28
29
30
31
32
  - id: check-yaml
  - id: debug-statements
  - id: end-of-file-fixer
  - id: mixed-line-ending
  - id: requirements-txt-fixer
  - id: trailing-whitespace

33
# Upgrade old Python syntax
34
- repo: https://github.com/asottile/pyupgrade
35
  rev: v2.31.0
36
37
  hooks:
  - id: pyupgrade
38
    args: [--py3-plus]
39

40
# Nicely sort includes
41
- repo: https://github.com/PyCQA/isort
42
  rev: 5.10.1
43
44
45
  hooks:
  - id: isort

46
47
# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
48
  rev: 22.1.0 # Keep in sync with blacken-docs
49
50
  hooks:
  - id: black
51

52
# Also code format the docs
53
- repo: https://github.com/asottile/blacken-docs
54
  rev: v1.12.1
55
56
57
  hooks:
  - id: blacken-docs
    additional_dependencies:
58
    - black==22.1.0 # keep in sync with black hook
59
60

# Changes tabs to spaces
61
- repo: https://github.com/Lucas-C/pre-commit-hooks
62
  rev: v1.1.11
63
64
65
  hooks:
  - id: remove-tabs

66
67
68
69
70
71
# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
  rev: v1.1.0
  hooks:
  - id: pycln

72
# Checking for common mistakes
73
74
75
76
77
78
- repo: https://github.com/pre-commit/pygrep-hooks
  rev: v1.9.0
  hooks:
  - id: python-check-blanket-noqa
  - id: python-check-blanket-type-ignore
  - id: python-no-log-warn
79
80
  # Python 3.6
  # - id: python-use-type-annotations
81
82
83
84
  - id: rst-backticks
  - id: rst-directive-colons
  - id: rst-inline-touching-normal

85
# Flake8 also supports pre-commit natively (same author)
86
- repo: https://github.com/PyCQA/flake8
87
  rev: 4.0.1
88
89
  hooks:
  - id: flake8
90
91
92
    additional_dependencies: &flake8_dependencies
      - flake8-bugbear
      - pep8-naming
93
    exclude: ^(docs/.*|tools/.*)$
94

95
# Automatically remove noqa that are not used
96
- repo: https://github.com/asottile/yesqa
97
  rev: v1.3.0
98
99
100
101
  hooks:
  - id: yesqa
    additional_dependencies: *flake8_dependencies

102
# CMake formatting
103
- repo: https://github.com/cheshirekow/cmake-format-precommit
Henry Schreiner's avatar
Henry Schreiner committed
104
  rev: v0.6.13
105
106
107
  hooks:
  - id: cmake-format
    additional_dependencies: [pyyaml]
Henry Schreiner's avatar
Henry Schreiner committed
108
109
    types: [file]
    files: (\.cmake|CMakeLists.txt)(.in)?$
110

111
112
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
113
  rev: v0.931
114
115
  hooks:
  - id: mypy
116
117
118
    args: [--show-error-codes]
    exclude: ^(tests|docs)/
    additional_dependencies: [nox, rich]
119

120
121
# Checks the manifest for missing files (native support)
- repo: https://github.com/mgedmin/check-manifest
122
  rev: "0.47"
123
124
125
126
127
128
  hooks:
  - id: check-manifest
    # This is a slow hook, so only run this if --hook-stage manual is passed
    stages: [manual]
    additional_dependencies: [cmake, ninja]

129
# Check for spelling
130
131
132
133
- repo: https://github.com/codespell-project/codespell
  rev: v2.1.0
  hooks:
  - id: codespell
134
135
    exclude: ".supp$"
    args: ["-L", "nd,ot,thist"]
136

137
# Check for common shell mistakes
138
- repo: https://github.com/shellcheck-py/shellcheck-py
139
  rev: v0.8.0.4
140
141
  hooks:
  - id: shellcheck
142

143
# Disallow some common capitalization mistakes
144
145
146
147
148
- repo: local
  hooks:
  - id: disallow-caps
    name: Disallow improper capitalization
    language: pygrep
149
    entry: PyBind|Numpy|Cmake|CCache|PyTest
150
    exclude: ^\.pre-commit-config.yaml$
151

152
# Clang format the codebase automatically
153
154
- repo: https://github.com/pre-commit/mirrors-clang-format
  rev: "v13.0.0"
155
  hooks:
156
  - id: clang-format