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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 6bf629a0909 Fix mypy prek hooks skipping all files in dot-directory 
(#70064)
6bf629a0909 is described below

commit 6bf629a09098ab859fb91e716b2f04cb3ef7dcbe
Author: PoAn Yang <[email protected]>
AuthorDate: Sun Jul 19 06:55:30 2026 +0900

    Fix mypy prek hooks skipping all files in dot-directory (#70064)
    
    Signed-off-by: PoAn Yang <[email protected]>
---
 scripts/ci/prek/common_prek_utils.py                     |  5 +++++
 scripts/ci/prek/mypy_folder.py                           |  3 ++-
 .../run_mypy_full_dist_local_venv_or_breeze_in_ci.py     |  3 ++-
 scripts/tests/ci/prek/test_common_prek_utils.py          | 16 ++++++++++++++++
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/scripts/ci/prek/common_prek_utils.py 
b/scripts/ci/prek/common_prek_utils.py
index 26e49175ce6..2f960aa3e32 100644
--- a/scripts/ci/prek/common_prek_utils.py
+++ b/scripts/ci/prek/common_prek_utils.py
@@ -178,6 +178,11 @@ def pre_process_mypy_files(files: list[str]) -> list[str]:
     return [file for file in files if not file.startswith("providers")]
 
 
+def is_hidden_within_root(path: Path, root: Path) -> bool:
+    """Whether any path component below ``root`` is dot-prefixed."""
+    return any(part.startswith(".") for part in path.relative_to(root).parts)
+
+
 def insert_documentation(
     file_path: Path,
     content: list[str],
diff --git a/scripts/ci/prek/mypy_folder.py b/scripts/ci/prek/mypy_folder.py
index 8825102c0ac..43106cf6201 100755
--- a/scripts/ci/prek/mypy_folder.py
+++ b/scripts/ci/prek/mypy_folder.py
@@ -34,6 +34,7 @@ from common_prek_utils import (
     console,
     get_all_provider_ids,
     initialize_breeze_prek,
+    is_hidden_within_root,
     run_command_via_breeze_run,
 )
 
@@ -110,7 +111,7 @@ def get_all_files(folder: str) -> list[str]:
     for file in python_file_paths:
         if (
             (file.name not in ("conftest.py",) and not 
any(x.match(file.as_posix()) for x in exclude_regexps))
-            and not any(part.startswith(".") for part in file.parts)
+            and not is_hidden_within_root(file, AIRFLOW_ROOT_PATH)
         ) and not 
file.as_posix().endswith("src/airflow/providers/__init__.py"):
             
files_to_check.append(file.relative_to(AIRFLOW_ROOT_PATH).as_posix())
     file_spec = "@/files/mypy_files.txt"
diff --git a/scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py 
b/scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py
index ca9f09adae6..66b8db86f6e 100755
--- a/scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py
+++ b/scripts/ci/prek/run_mypy_full_dist_local_venv_or_breeze_in_ci.py
@@ -40,6 +40,7 @@ from pathlib import Path
 from common_prek_utils import (
     AIRFLOW_ROOT_PATH,
     check_uv_version,
+    is_hidden_within_root,
 )
 
 CI = os.environ.get("CI")
@@ -138,7 +139,7 @@ def get_all_files(folder: str) -> list[str]:
         if (
             file.name not in ("conftest.py",)
             and not any(x.match(file.as_posix()) for x in exclude_regexps)
-            and not any(part.startswith(".") for part in file.parts)
+            and not is_hidden_within_root(file, AIRFLOW_ROOT_PATH)
         ):
             
files_to_check.append(file.relative_to(AIRFLOW_ROOT_PATH).as_posix())
     return files_to_check
diff --git a/scripts/tests/ci/prek/test_common_prek_utils.py 
b/scripts/tests/ci/prek/test_common_prek_utils.py
index 9c011f8f53c..f28961f9006 100644
--- a/scripts/tests/ci/prek/test_common_prek_utils.py
+++ b/scripts/tests/ci/prek/test_common_prek_utils.py
@@ -29,6 +29,7 @@ from ci.prek.common_prek_utils import (
     get_provider_id_from_path,
     initialize_breeze_prek,
     insert_documentation,
+    is_hidden_within_root,
     pre_process_mypy_files,
     read_airflow_version,
     read_allowed_kubernetes_versions,
@@ -170,6 +171,21 @@ class TestPreProcessMypyFiles:
         assert PROVIDERS_AMAZON_S3_PATH in result
 
 
+class TestIsHiddenWithinRoot:
+    @pytest.mark.parametrize(
+        ("relative_path", "expected"),
+        [
+            ("airflow-core/src/airflow/models/dag.py", False),
+            (".build/mypy-venvs/foo.py", True),
+            ("airflow-core/.venv/lib/foo.py", True),
+            (".hidden.py", True),
+        ],
+    )
+    def test_only_components_below_root_count(self, tmp_path, relative_path, 
expected):
+        root = tmp_path / ".claude" / "worktrees"
+        assert is_hidden_within_root(root / relative_path, root) is expected
+
+
 class TestGetImportsFromFile:
     def test_simple_import(self, write_python_file):
         path = write_python_file("import os\nimport sys\n")

Reply via email to