From 1723ff98f21240f0e0dbbdbcfa8402526a5552c4 Mon Sep 17 00:00:00 2001 From: "Guan-Ming (Wesley) Chiu" <105915352+guan404ming@users.noreply.github.com> Date: Fri, 21 Nov 2025 18:46:10 +0800 Subject: [PATCH] Update file patterns for specific linting hooks --- .pre-commit-config.yaml | 18 +++++++++--------- docker/lint.sh | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d455a1450068..13a06a6cb3db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ default_language_version: python: python3.9 fail_fast: True -default_stages: [pre-push] +default_stages: [pre-push, pre-commit] repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 @@ -49,9 +49,9 @@ repos: hooks: - id: run-black name: Running Black... - entry: docker/lint.sh python_format + entry: docker/lint.sh python_format -i language: system - always_run: true + files: \.py$ pass_filenames: false - id: run-file-checks name: Checking File Types.... @@ -61,25 +61,25 @@ repos: pass_filenames: false - id: run-headers-check name: Checking ASF License Headers ... - entry: docker/lint.sh asf + entry: docker/lint.sh asf -i language: system always_run: true pass_filenames: false - - id: run-headers-check + - id: run-cpplint name: Linting the C++ code ... entry: docker/lint.sh cpplint language: system - always_run: true + files: \.(c|cc|cpp|h|hpp)$ pass_filenames: false - id: run-clang-format name: Checking Clang format ... - entry: docker/lint.sh clang_format + entry: docker/lint.sh clang_format -i language: system - always_run: true + files: \.(c|cc|cpp|h|hpp)$ pass_filenames: false - id: run-mypy name: Type Checking with MyPY ... entry: docker/lint.sh mypy language: system - always_run: true + files: \.py$ pass_filenames: false diff --git a/docker/lint.sh b/docker/lint.sh index 4f7bca445a9f..32e01d3b7268 100755 --- a/docker/lint.sh +++ b/docker/lint.sh @@ -90,7 +90,11 @@ function run_lint_step() { shift if [ $validate_only -eq 0 ]; then - run_docker -it "ci_lint" "${cmd[@]}" + if [ -t 0 ]; then + run_docker -it "ci_lint" "${cmd[@]}" + else + run_docker "ci_lint" "${cmd[@]}" + fi fi }