mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:50:14 +01:00
pre-commit autoupdate --freeze && pre-commit run -a
This update may be triggering incompatibilities with old installs. If you see an issue such as:
```
An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
```
Try updating pip packages, particularly:
```
pip3 install -U pre-commit
pip3 install -U virtualenv
```
207 lines
6.7 KiB
YAML
207 lines
6.7 KiB
YAML
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
# Exceptions. See /LICENSE for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
# Update versions with:
|
|
# pre-commit autoupdate --freeze && pre-commit run -a
|
|
# See https://pre-commit.com for more information
|
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
|
|
default_language_version:
|
|
python: python3 # Defaults to python2, so override it.
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
|
|
hooks:
|
|
- id: check-added-large-files
|
|
- id: check-case-conflict
|
|
- id: check-executables-have-shebangs
|
|
- id: check-merge-conflict
|
|
- id: check-symlinks
|
|
exclude: ^bazel-execroot$
|
|
- id: check-yaml
|
|
- id: detect-private-key
|
|
- id: end-of-file-fixer
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*\.svg)$'
|
|
- id: mixed-line-ending
|
|
args: ['--fix=lf']
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*\.svg)$'
|
|
- id: trailing-whitespace
|
|
exclude: '^(.*/fuzzer_corpus/.*|.*/testdata/.*\.golden|.*\.svg)$'
|
|
- repo: https://github.com/google/pre-commit-tool-hooks
|
|
rev: e006c8ab09f96ec32ba728b488ea5d17e1f8f6c0 # frozen: v1.2.4
|
|
hooks:
|
|
- id: check-google-doc-style
|
|
- id: markdown-toc
|
|
- repo: local
|
|
hooks:
|
|
- id: fix-cc-deps
|
|
name: Fix missing C++ deps
|
|
entry: scripts/fix_cc_deps.py
|
|
language: python
|
|
files: ^.*/(BUILD|[^/]+\.(h|cpp))$
|
|
pass_filenames: false
|
|
|
|
# Formatters should be run late so that they can re-format any prior changes.
|
|
- repo: https://github.com/psf/black
|
|
rev: b0d1fba7ac3be53c71fb0d3211d911e629f8aecb # frozen: 23.1.0
|
|
hooks:
|
|
- id: black
|
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
rev: cafd5506f18eea191804850dacc0a4264772d59d # frozen: v3.0.0-alpha.4
|
|
hooks:
|
|
- id: prettier
|
|
- repo: local
|
|
hooks:
|
|
- id: buildifier
|
|
name: Bazel buildifier
|
|
entry: scripts/run_buildifier.py
|
|
args: ['-r', '.']
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
.*BUILD.*|
|
|
.*WORKSPACE.*|
|
|
.*\.bzl
|
|
)$
|
|
- id: clang-format
|
|
name: clang-format
|
|
entry: clang-format
|
|
types_or: [c++, proto]
|
|
language: python
|
|
args: ['-i']
|
|
additional_dependencies: ['clang-format==14.0.6']
|
|
- id: explorer-format-grammar
|
|
name: Format the explorer grammar file
|
|
entry: explorer/syntax/format_grammar.py
|
|
language: python
|
|
files: ^explorer/syntax/(lexer.lpp|parser.ypp)$
|
|
pass_filenames: false
|
|
additional_dependencies: ['clang-format==14.0.6']
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: check-header-guards
|
|
# This should run after clang-format, which may reformat a guard.
|
|
name: Check header guards
|
|
entry: scripts/check_header_guards.py
|
|
language: python
|
|
files: ^.*\.h$
|
|
- id: check-sha-filenames
|
|
# This may rename files, so it's deliberately between formatters and
|
|
# linters.
|
|
name: Check fuzzer SHA filenames
|
|
entry: scripts/check_sha_filenames.py
|
|
language: python
|
|
files: ^.*/fuzzer_corpus/.*$
|
|
- id: check-toolchain-diagnostics
|
|
name: Check toolchain diagnostics
|
|
entry: toolchain/diagnostics/check_diagnostics.py
|
|
language: python
|
|
files: |
|
|
(?x)^(
|
|
toolchain/.*\.cpp|
|
|
toolchain/.*\.h|
|
|
toolchain/diagnostics/diagnostic_registry\.def
|
|
)$
|
|
|
|
# Run linters last, as formatters and other checks may fix issues.
|
|
- repo: local
|
|
hooks:
|
|
- id: forbid-llvm-googletest
|
|
name: Checks for deps on LLVM's version of GoogleTest
|
|
entry: scripts/forbid_llvm_googletest.py
|
|
language: python
|
|
files: ^.*/BUILD$
|
|
pass_filenames: false
|
|
- repo: https://github.com/PyCQA/flake8
|
|
rev: c838a5e98878f17889cfce311e1406d252f87ec5 # frozen: 6.0.0
|
|
hooks:
|
|
- id: flake8
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: '0b037c2b59aa62dc3be3287d175295f1a5547eb9' # frozen: v0.991
|
|
hooks:
|
|
- id: mypy
|
|
# Use setup.cfg to match the command line.
|
|
args:
|
|
- --config-file=setup.cfg
|
|
# This should match the requirements added in the WORKSPACE pip_install.
|
|
additional_dependencies:
|
|
- gql >= 2.0.0, < 3.0.0
|
|
- PyGitHub
|
|
# Exclusions are:
|
|
# - p#### scripts because they're not tested or maintained.
|
|
# - lit.cfg.py because it has multiple copies, breaking mypy.
|
|
# - Unit tests because they sometimes violate typing, such as by
|
|
# assigning a mock to a function.
|
|
exclude: |
|
|
(?x)^(
|
|
proposals/(?!scripts/).*|
|
|
.*/lit\.cfg\.py|
|
|
.*_test\.py
|
|
)$
|
|
- repo: https://github.com/codespell-project/codespell
|
|
rev: 055cb2a9bc1e98a9800a352c53c38a50faf62dc3 # frozen: v2.2.2
|
|
hooks:
|
|
- id: codespell
|
|
args: ['-I', '.codespell_ignore', '--uri-ignore-words-list', '*']
|
|
# Test data may contain intentional misspellings, as well as short,
|
|
# meaningless identifiers that codespell incorrectly identifies as
|
|
# typos but that we would want to detect in other contexts.
|
|
exclude: |
|
|
(?x)^(
|
|
.*/testdata/.*|
|
|
.*/fuzzer_corpus/.*
|
|
)$
|
|
- repo: https://github.com/google/pre-commit-tool-hooks
|
|
rev: e006c8ab09f96ec32ba728b488ea5d17e1f8f6c0 # frozen: v1.2.4
|
|
hooks:
|
|
- id: check-copyright
|
|
args:
|
|
- --copyright
|
|
- |+
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
- --custom_format
|
|
- '\.(carbon|proto|ypp)$'
|
|
- ''
|
|
- '// '
|
|
- ''
|
|
- --custom_format
|
|
- '\.(l|lpp|y)$'
|
|
- '/*'
|
|
- ''
|
|
- '*/'
|
|
- --custom_format
|
|
- '\.(plist)$'
|
|
- '<!--'
|
|
- ''
|
|
- '\-->'
|
|
- --custom_format
|
|
- '\.vim$'
|
|
- ''
|
|
- '" '
|
|
- ''
|
|
exclude: |
|
|
(?x)^(
|
|
.bazelversion|
|
|
.github/pull_request_template.md|
|
|
compile_flags.txt|
|
|
third_party/.*|
|
|
.*\.def|
|
|
.*\.svg|
|
|
.*/fuzzer_corpus/.*|
|
|
.*/testdata/.*\.golden
|
|
)$
|
|
- id: check-links
|
|
|
|
# This excludes third-party code, and patches to third-party code.
|
|
exclude: |
|
|
(?x)^(
|
|
bazel/patches/.*\.patch|
|
|
third_party/examples/.*/carbon/.*|
|
|
third_party/llvm-project/.*|
|
|
)$
|