.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.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.1"
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.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.13"
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: "v1.2.5"
75
76
77
  hooks:
  - id: pycln

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

Henry Schreiner's avatar
Henry Schreiner committed
90
91
92
93
94
95
96
97
98
# 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

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

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

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

123
124
# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
125
  rev: "v0.940"
126
127
  hooks:
  - id: mypy
128
129
130
    args: [--show-error-codes]
    exclude: ^(tests|docs)/
    additional_dependencies: [nox, rich]
131

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

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

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

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

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