This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-0-test by this push:
     new a630ac7f28b Remove black usage in prek hooks (#54656) (#54664)
a630ac7f28b is described below

commit a630ac7f28b568afe03e1f4d04ce457d7241fec9
Author: Wei Lee <[email protected]>
AuthorDate: Tue Aug 19 21:46:40 2025 +0800

    Remove black usage in prek hooks (#54656) (#54664)
    
    We are not using black-related functionality in prek hooks any more - the
    only remaining hook is 'blacken-docs` - but there is no need to synchronize
    and upgrade black version any more for it.
    
    Upgraded to latest black version for blacken-docs manually.
    
    (cherry picked from commit 4e6fa29117255b7c231672ca643ff21ff91f833b)
    
    Co-authored-by: Jarek Potiuk <[email protected]>
---
 .github/workflows/basic-tests.yml          |  7 -----
 .pre-commit-config.yaml                    | 15 +++-------
 scripts/ci/prek/common_prek_black_utils.py | 44 ------------------------------
 scripts/ci/prek/update_black_version.py    | 34 -----------------------
 4 files changed, 4 insertions(+), 96 deletions(-)

diff --git a/.github/workflows/basic-tests.yml 
b/.github/workflows/basic-tests.yml
index 4be6b383d08..d289793ac00 100644
--- a/.github/workflows/basic-tests.yml
+++ b/.github/workflows/basic-tests.yml
@@ -265,13 +265,6 @@ jobs:
       #   run: prek autoupdate --bleeding-edge --freeze --repo 
https://github.com/Lucas-C/pre-commit-hooks
       # - name: "Check if there are any changes in pre-commit hooks"
       #   run: git diff --exit-code
-      - name: "Run automated upgrade for black"
-        run: >
-          prek
-          --all-files --show-diff-on-failure --color always --verbose
-          --hook-stage manual
-          update-black-version
-        if: always()
       - name: "Run automated upgrade for chart dependencies"
         run: >
           prek
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fed0f72e15a..132a88757b2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -187,15 +187,6 @@ repos:
         additional_dependencies: ['rich>=12.4.4', 'ruff==0.11.2']
         files: ^providers/.*/src/airflow/providers/.*\.py$
         require_serial: true
-      - id: update-black-version
-        name: Update black versions everywhere (manual)
-        entry: ./scripts/ci/prek/update_black_version.py
-        stages: ['manual']
-        language: python
-        files: ^\.pre-commit-config\.yaml$
-        additional_dependencies: ['pyyaml>=6.0.2']
-        pass_filenames: false
-        require_serial: true
       - id: upgrade-important-versions
         name: Upgrade important versions (manual)
         entry: ./scripts/ci/prek/upgrade_important_versions.py
@@ -246,8 +237,10 @@ repos:
           - --target-version=py310
           - --target-version=py311
           - --target-version=py312
+          - --target-version=py313
         alias: blacken-docs
-        additional_dependencies: ['black==24.10.0']
+        additional_dependencies:
+         - 'black==25.1.0'
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c  # frozen: v6.0.0
     hooks:
@@ -909,7 +902,7 @@ repos:
         entry: ./scripts/ci/prek/check_integrations_list.py
         language: python
         files: 
^scripts/ci/docker-compose/integration-.*\.yml$|^contributing-docs/testing/integration_tests\.rst$
-        additional_dependencies: ['black==24.10.0', 'tabulate>=0.9.0', 
'rich>=12.4.4', 'pyyaml>=6.0.2']
+        additional_dependencies: ['tabulate>=0.9.0', 'rich>=12.4.4', 
'pyyaml>=6.0.2']
         require_serial: true
         pass_filenames: false
       - id: update-breeze-readme-config-hash
diff --git a/scripts/ci/prek/common_prek_black_utils.py 
b/scripts/ci/prek/common_prek_black_utils.py
deleted file mode 100644
index 5f6e0a87778..00000000000
--- a/scripts/ci/prek/common_prek_black_utils.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from __future__ import annotations
-
-import os
-import sys
-from functools import cache
-from pathlib import Path
-
-from black import Mode, TargetVersion, format_str, parse_pyproject_toml
-
-sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure 
common_prek_utils is imported
-
-from common_prek_utils import AIRFLOW_BREEZE_SOURCES_PATH
-
-
-@cache
-def black_mode(is_pyi: bool = Mode.is_pyi) -> Mode:
-    config = parse_pyproject_toml(os.fspath(AIRFLOW_BREEZE_SOURCES_PATH / 
"pyproject.toml"))
-    target_versions = {TargetVersion[val.upper()] for val in 
config.get("target_version", ())}
-
-    return Mode(
-        target_versions=target_versions,
-        line_length=config.get("line_length", Mode.line_length),
-        is_pyi=is_pyi,
-    )
-
-
-def black_format(content: str, is_pyi: bool = Mode.is_pyi) -> str:
-    return format_str(content, mode=black_mode(is_pyi=is_pyi))
diff --git a/scripts/ci/prek/update_black_version.py 
b/scripts/ci/prek/update_black_version.py
deleted file mode 100755
index 4d1b98ef310..00000000000
--- a/scripts/ci/prek/update_black_version.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from __future__ import annotations
-
-import re
-
-import yaml
-from common_prek_utils import AIRFLOW_ROOT_PATH
-
-if __name__ == "__main__":
-    PRE_COMMIT_CONFIG_FILE = AIRFLOW_ROOT_PATH / ".pre-commit-config.yaml"
-    pre_commit_config_content = 
yaml.safe_load(PRE_COMMIT_CONFIG_FILE.read_text())
-    for repo in pre_commit_config_content["repos"]:
-        if repo["repo"] == "https://github.com/psf/black":
-            black_version = repo["rev"]
-            pre_commit_text = PRE_COMMIT_CONFIG_FILE.read_text()
-            pre_commit_text = re.sub(r"black==[0-9\.]*", 
f"black=={black_version}", pre_commit_text)
-            PRE_COMMIT_CONFIG_FILE.write_text(pre_commit_text)
-            break

Reply via email to