pre-commit accepts exclude keys which take python regular expressions, typically designed with regex101. For example:

 1exclude: |
 2  (?x)(
 3  thirdparty| # vendored
 4  xtb.h| # vendored
 5  )
 6- id: clang-format
 7  name: clang-format
 8  entry: clang-format
 9  language: system
10  types_or: [c, c++, cuda]
11  args: ["-fallback-style=none", "-style=file", "-i"]

While it is especially useful for tools which don’t have ignore flags, as a convention:

  • Use a globally defined exclude
    • Explain the exclusion with a comment
  • Fine-tune with per-hook types_or (or even files)
    • Additional exclude keys may be used as well