.pre-commit-config.yaml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. repos:
  15. # Standard hooks
  16. - repo: https://github.com/pre-commit/pre-commit-hooks
  17. rev: v4.0.1
  18. hooks:
  19. - id: check-added-large-files
  20. - id: check-case-conflict
  21. - id: check-merge-conflict
  22. - id: check-symlinks
  23. - id: check-yaml
  24. - id: debug-statements
  25. - id: end-of-file-fixer
  26. - id: mixed-line-ending
  27. - id: requirements-txt-fixer
  28. - id: trailing-whitespace
  29. - id: fix-encoding-pragma
  30. exclude: ^noxfile.py$
  31. - repo: https://github.com/asottile/pyupgrade
  32. rev: v2.23.1
  33. hooks:
  34. - id: pyupgrade
  35. # Black, the code formatter, natively supports pre-commit
  36. - repo: https://github.com/psf/black
  37. rev: 21.7b0
  38. hooks:
  39. - id: black
  40. # By default, this ignores pyi files, though black supports them
  41. types: [text]
  42. files: \.pyi?$
  43. # Changes tabs to spaces
  44. - repo: https://github.com/Lucas-C/pre-commit-hooks
  45. rev: v1.1.10
  46. hooks:
  47. - id: remove-tabs
  48. # Flake8 also supports pre-commit natively (same author)
  49. - repo: https://github.com/PyCQA/flake8
  50. rev: 3.9.2
  51. hooks:
  52. - id: flake8
  53. additional_dependencies: [flake8-bugbear, pep8-naming]
  54. exclude: ^(docs/.*|tools/.*)$
  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. # Check static types with mypy
  64. - repo: https://github.com/pre-commit/mirrors-mypy
  65. rev: v0.910
  66. hooks:
  67. - id: mypy
  68. # The default Python type ignores .pyi files, so let's rerun if detected
  69. types: [text]
  70. files: ^pybind11.*\.pyi?$
  71. # Running per-file misbehaves a bit, so just run on all files, it's fast
  72. pass_filenames: false
  73. additional_dependencies: [typed_ast]
  74. # Checks the manifest for missing files (native support)
  75. - repo: https://github.com/mgedmin/check-manifest
  76. rev: "0.46"
  77. hooks:
  78. - id: check-manifest
  79. # This is a slow hook, so only run this if --hook-stage manual is passed
  80. stages: [manual]
  81. additional_dependencies: [cmake, ninja]
  82. - repo: https://github.com/codespell-project/codespell
  83. rev: v2.1.0
  84. hooks:
  85. - id: codespell
  86. exclude: ".supp$"
  87. args: ["-L", "nd,ot,thist"]
  88. - repo: https://github.com/shellcheck-py/shellcheck-py
  89. rev: v0.7.2.1
  90. hooks:
  91. - id: shellcheck
  92. # The original pybind11 checks for a few C++ style items
  93. - repo: local
  94. hooks:
  95. - id: disallow-caps
  96. name: Disallow improper capitalization
  97. language: pygrep
  98. entry: PyBind|Numpy|Cmake|CCache|PyTest
  99. exclude: .pre-commit-config.yaml
  100. - repo: local
  101. hooks:
  102. - id: check-style
  103. name: Classic check-style
  104. language: system
  105. types:
  106. - c++
  107. entry: ./tools/check-style.sh