.pre-commit-config.yaml 3.93 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.3.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.37.3"
36
37
  hooks:
  - id: pyupgrade
38
    args: [--py36-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.6.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.6.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.3.0"
63
64
65
  hooks:
  - id: remove-tabs

66
- repo: https://github.com/sirosen/texthooks
67
  rev: "0.3.1"
68
69
70
71
  hooks:
  - id: fix-ligatures
  - id: fix-smartquotes

72
73
# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
74
  rev: "v2.1.1"
75
76
  hooks:
  - id: pycln
Henry Schreiner's avatar
Henry Schreiner committed
77
    stages: [manual]
78

79
# Checking for common mistakes
80
- repo: https://github.com/pre-commit/pygrep-hooks
81
  rev: "v1.9.0"
82
83
84
85
  hooks:
  - id: python-check-blanket-noqa
  - id: python-check-blanket-type-ignore
  - id: python-no-log-warn
86
  - id: python-use-type-annotations
87
88
89
90
  - id: rst-backticks
  - id: rst-directive-colons
  - id: rst-inline-touching-normal

Henry Schreiner's avatar
Henry Schreiner committed
91
92
93
94
95
96
97
98
99
# Automatically remove noqa that are not used
- repo: https://github.com/asottile/yesqa
  rev: "v1.3.0"
  hooks:
  - id: yesqa
    additional_dependencies: &flake8_dependencies
      - flake8-bugbear
      - pep8-naming

100
# Flake8 also supports pre-commit natively (same author)
101
- repo: https://github.com/PyCQA/flake8
102
  rev: "5.0.2"
103
104
105
  hooks:
  - id: flake8
    exclude: ^(docs/.*|tools/.*)$
Henry Schreiner's avatar
Henry Schreiner committed
106
    additional_dependencies: *flake8_dependencies
107

Henry Schreiner's avatar
Henry Schreiner committed
108
109
# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
110
  rev: "v2.14.5"
111
  hooks:
Henry Schreiner's avatar
Henry Schreiner committed
112
113
  - id: pylint
    files: ^pybind11
114

115
# CMake formatting
116
- repo: https://github.com/cheshirekow/cmake-format-precommit
117
  rev: "v0.6.13"
118
119
120
  hooks:
  - id: cmake-format
    additional_dependencies: [pyyaml]
Henry Schreiner's avatar
Henry Schreiner committed
121
122
    types: [file]
    files: (\.cmake|CMakeLists.txt)(.in)?$
123

124
125
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
126
  rev: "v0.971"
127
128
  hooks:
  - id: mypy
Henry Schreiner's avatar
Henry Schreiner committed
129
    args: []
130
131
    exclude: ^(tests|docs)/
    additional_dependencies: [nox, rich]
132

133
134
# Checks the manifest for missing files (native support)
- repo: https://github.com/mgedmin/check-manifest
135
  rev: "0.48"
136
137
138
139
140
141
  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]

142
# Check for spelling
143
- repo: https://github.com/codespell-project/codespell
144
  rev: "v2.1.0"
145
146
  hooks:
  - id: codespell
147
148
    exclude: ".supp$"
    args: ["-L", "nd,ot,thist"]
149

150
# Check for common shell mistakes
151
- repo: https://github.com/shellcheck-py/shellcheck-py
152
  rev: "v0.8.0.4"
153
154
  hooks:
  - id: shellcheck
155

156
# Disallow some common capitalization mistakes
157
158
159
160
161
- repo: local
  hooks:
  - id: disallow-caps
    name: Disallow improper capitalization
    language: pygrep
162
    entry: PyBind|Numpy|Cmake|CCache|PyTest
163
    exclude: ^\.pre-commit-config.yaml$
164

165
# Clang format the codebase automatically
166
- repo: https://github.com/pre-commit/mirrors-clang-format
167
  rev: "v14.0.6"
168
  hooks:
169
  - id: clang-format
170
    types_or: [c++, c, cuda]