From d935df59e634f6139619ee0127f7affc67ceeafe Mon Sep 17 00:00:00 2001 From: Shangjie Chen Date: Thu, 23 Apr 2026 14:25:06 -0700 Subject: [PATCH] chore: Add pre-commit hooks for code formatting and licensing Co-authored-by: Shangjie Chen PiperOrigin-RevId: 904636630 --- .pre-commit-config.yaml | 47 ++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bf1047a..beb13019 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,22 +13,39 @@ # limitations under the License. repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - - id: check-added-large-files - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace -- repo: local + - id: check-added-large-files + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/tox-dev/pyproject-fmt + rev: v2.5.0 hooks: - - id: isort - name: isort - entry: isort + - id: pyproject-fmt + - repo: https://github.com/PyCQA/isort + rev: 8.0.1 + hooks: + - id: isort + - repo: https://github.com/google/pyink + rev: 25.12.0 + hooks: + - id: pyink + - repo: local + hooks: + - id: addlicense + name: addlicense + entry: > + bash -c 'if command -v addlicense >/dev/null 2>&1; + then addlicense -c "Google LLC" -l apache "$@"; + else echo "Warning: addlicense not installed, skipping"; fi' -- language: system - types: [python] - - id: pyink - name: pyink - entry: pyink --config pyproject.toml - language: system - types: [python] + files: \.(py|sh)$ + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.22 + hooks: + - id: mdformat + files: ^(README\.md|CONTRIBUTING\.md|contributing/.*\.md)$ + additional_dependencies: + - mdformat-gfm