• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# To use:
2#
3#     pre-commit run -a
4#
5# Or:
6#
7#     pre-commit install  # (runs every time you commit in git)
8#
9# To update this file:
10#
11#     pre-commit autoupdate
12#
13# See https://github.com/pre-commit/pre-commit
14
15repos:
16# Standard hooks
17- repo: https://github.com/pre-commit/pre-commit-hooks
18  rev: v3.4.0
19  hooks:
20  - id: check-added-large-files
21  - id: check-case-conflict
22  - id: check-merge-conflict
23  - id: check-symlinks
24  - id: check-yaml
25  - id: debug-statements
26  - id: end-of-file-fixer
27  - id: mixed-line-ending
28  - id: requirements-txt-fixer
29  - id: trailing-whitespace
30  - id: fix-encoding-pragma
31
32# Black, the code formatter, natively supports pre-commit
33- repo: https://github.com/psf/black
34  rev: 20.8b1
35  hooks:
36  - id: black
37    # By default, this ignores pyi files, though black supports them
38    types: [text]
39    files: \.pyi?$
40
41# Changes tabs to spaces
42- repo: https://github.com/Lucas-C/pre-commit-hooks
43  rev: v1.1.9
44  hooks:
45  - id: remove-tabs
46
47# Flake8 also supports pre-commit natively (same author)
48- repo: https://gitlab.com/pycqa/flake8
49  rev: 3.8.4
50  hooks:
51  - id: flake8
52    additional_dependencies: [flake8-bugbear, pep8-naming]
53    exclude: ^(docs/.*|tools/.*)$
54
55# CMake formatting
56- repo: https://github.com/cheshirekow/cmake-format-precommit
57  rev: v0.6.13
58  hooks:
59  - id: cmake-format
60    additional_dependencies: [pyyaml]
61    types: [file]
62    files: (\.cmake|CMakeLists.txt)(.in)?$
63
64# Check static types with mypy
65- repo: https://github.com/pre-commit/mirrors-mypy
66  rev: v0.800
67  hooks:
68  - id: mypy
69    # The default Python type ignores .pyi files, so let's rerun if detected
70    types: [text]
71    files: ^pybind11.*\.pyi?$
72    # Running per-file misbehaves a bit, so just run on all files, it's fast
73    pass_filenames: false
74
75# Checks the manifest for missing files (native support)
76- repo: https://github.com/mgedmin/check-manifest
77  rev: "0.46"
78  hooks:
79  - id: check-manifest
80    # This is a slow hook, so only run this if --hook-stage manual is passed
81    stages: [manual]
82    additional_dependencies: [cmake, ninja]
83
84# The original pybind11 checks for a few C++ style items
85- repo: local
86  hooks:
87  - id: disallow-caps
88    name: Disallow improper capitalization
89    language: pygrep
90    entry: PyBind|Numpy|Cmake|CCache
91    exclude: .pre-commit-config.yaml
92
93- repo: local
94  hooks:
95  - id: check-style
96    name: Classic check-style
97    language: system
98    types:
99    - c++
100    entry: ./tools/check-style.sh
101