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

vatsrahul1001 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 e64cb9442e7 Stop using deprecated pathspec GitWildMatchPattern for 
.airflowignore (#77567)
e64cb9442e7 is described below

commit e64cb9442e793c2dae6526d04b4fe0cc1a0c768f
Author: Vishak Baddur <[email protected]>
AuthorDate: Mon Nov 30 13:25:07 2026 -0600

    Stop using deprecated pathspec GitWildMatchPattern for .airflowignore 
(#77567)
    
    pathspec 1.0 deprecates GitWildMatchPattern, which now only warns and
    delegates to GitIgnoreSpecPattern, so every glob .airflowignore pattern
    emitted two DeprecationWarnings. Use GitIgnoreSpecPattern directly, falling
    back to GitWildMatchPattern on pathspec < 1.0.
---
 .../src/airflow_shared/module_loading/file_discovery.py      |  9 ++++++---
 .../tests/module_loading/test_file_discovery.py              | 12 ++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git 
a/shared/module_loading/src/airflow_shared/module_loading/file_discovery.py 
b/shared/module_loading/src/airflow_shared/module_loading/file_discovery.py
index 4837a6bbb9b..4b84b6a428c 100644
--- a/shared/module_loading/src/airflow_shared/module_loading/file_discovery.py
+++ b/shared/module_loading/src/airflow_shared/module_loading/file_discovery.py
@@ -27,7 +27,10 @@ from pathlib import Path
 from re import Pattern
 from typing import NamedTuple, Protocol
 
-from pathspec.patterns import GitWildMatchPattern
+try:
+    from pathspec.patterns.gitignore.spec import GitIgnoreSpecPattern
+except ImportError:  # pathspec < 1.0
+    from pathspec.patterns import GitWildMatchPattern as GitIgnoreSpecPattern
 
 log = logging.getLogger(__name__)
 
@@ -77,7 +80,7 @@ class _RegexpIgnoreRule(NamedTuple):
 class _GlobIgnoreRule(NamedTuple):
     """Typed namedtuple with utility functions for glob ignore rules."""
 
-    wild_match_pattern: GitWildMatchPattern
+    wild_match_pattern: GitIgnoreSpecPattern
     relative_to: Path | None = None
     dir_only: bool = False
 
@@ -103,7 +106,7 @@ class _GlobIgnoreRule(NamedTuple):
         raw_pattern = pattern.lstrip("!")
         dir_only = raw_pattern.rstrip() != raw_pattern.rstrip().rstrip("/")
 
-        ignore_pattern = GitWildMatchPattern(pattern)
+        ignore_pattern = GitIgnoreSpecPattern(pattern)
         return _GlobIgnoreRule(wild_match_pattern=ignore_pattern, 
relative_to=relative_to, dir_only=dir_only)
 
     @staticmethod
diff --git a/shared/module_loading/tests/module_loading/test_file_discovery.py 
b/shared/module_loading/tests/module_loading/test_file_discovery.py
index 71dcfe5b818..54183b7dd83 100644
--- a/shared/module_loading/tests/module_loading/test_file_discovery.py
+++ b/shared/module_loading/tests/module_loading/test_file_discovery.py
@@ -18,6 +18,7 @@
 from __future__ import annotations
 
 import os
+import warnings
 from pathlib import Path
 
 import pytest
@@ -213,3 +214,14 @@ class TestFindPathFromDirectory:
                 detected.add(p.relative_to(dags_root).as_posix())
 
         assert detected == {"abc/def/xyz/xyz_dag.py"}
+
+    def test_glob_ignore_does_not_emit_deprecation_warning(self, tmp_path):
+        (tmp_path / "keep.py").write_text("")
+        (tmp_path / "skip.py").write_text("")
+        (tmp_path / ".airflowignore").write_text("skip.py\n")
+
+        with warnings.catch_warnings():
+            warnings.simplefilter("error", DeprecationWarning)
+            detected = {Path(p).name for p in 
find_path_from_directory(tmp_path, ".airflowignore", "glob")}
+
+        assert detected == {"keep.py"}

Reply via email to