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

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

commit 9b1ea19852a880cb7c13acd097beaf25d4664f10
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Oct 29 07:46:20 2026 +0000

    [v3-4-test] Support Python 3.11.0 in prek cache test (#75520) (#75850)
    
    The scripts package supports Python 3.11 from its initial patch release, 
but tarfile added the extractall filter argument in 3.11.4. Keep the opt-in 
cache integration test usable across the supported 3.11 patch range.
    (cherry picked from commit 62934e405ed20f10edaddb3a5dc19abd0050beda)
    
    Co-authored-by: Parv Goyal <[email protected]>
---
 scripts/tests/ci/test_prek_cache_optimizations.py | 38 ++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/scripts/tests/ci/test_prek_cache_optimizations.py 
b/scripts/tests/ci/test_prek_cache_optimizations.py
index 9696fbefd93..5da98527896 100644
--- a/scripts/tests/ci/test_prek_cache_optimizations.py
+++ b/scripts/tests/ci/test_prek_cache_optimizations.py
@@ -23,6 +23,7 @@ import shutil
 import subprocess
 import tarfile
 from pathlib import Path
+from unittest.mock import patch
 
 import pytest
 import yaml
@@ -76,6 +77,13 @@ def run_cache_step(step, env, tmp_path):
     return run_shell(script, env)
 
 
+def _extract_tar_archive(handle: tarfile.TarFile, path: Path) -> None:
+    if hasattr(tarfile, "data_filter"):
+        handle.extractall(path, filter="fully_trusted")
+    else:
+        handle.extractall(path)
+
+
 @pytest.fixture
 def fake_tools(tmp_path):
     tools = tmp_path / "bin"
@@ -325,6 +333,34 @@ def 
test_repaired_archive_is_reused_without_another_save(sandbox, fake_tools, tm
     assert read_outputs(sandbox) == {"save": "false", "reason": "unchanged"}
 
 
[email protected](
+    ("supports_data_filter", "expected_kwargs"),
+    [
+        (True, {"filter": "fully_trusted"}),
+        (False, {}),
+    ],
+)
+def test_extract_tar_archive_uses_supported_filter(
+    tmp_path, monkeypatch, supports_data_filter, expected_kwargs
+):
+    content = tmp_path / "content"
+    content.mkdir()
+    (content / "payload").write_text("cache data")
+    archive = tmp_path / "cache.tar.gz"
+    with tarfile.open(archive, "w:gz") as handle:
+        handle.add(content, arcname="cache")
+
+    if supports_data_filter:
+        monkeypatch.setattr(tarfile, "data_filter", lambda member, path: 
member, raising=False)
+    else:
+        monkeypatch.delattr(tarfile, "data_filter", raising=False)
+
+    with patch.object(tarfile.TarFile, "extractall", autospec=True) as 
extractall:
+        with tarfile.open(archive, "r:gz") as handle:
+            _extract_tar_archive(handle, tmp_path)
+        extractall.assert_called_once_with(handle, tmp_path, **expected_kwargs)
+
+
 @pytest.mark.skipif(
     os.environ.get("RUN_PREK_INTEGRATION") != "1",
     reason="Set RUN_PREK_INTEGRATION=1 to exercise real prek 0.5.2",
@@ -376,7 +412,7 @@ repos:
         handle.add(cache, arcname="prek-cache")
     shutil.rmtree(cache)
     with tarfile.open(archive, "r:gz") as handle:
-        handle.extractall(tmp_path, filter="fully_trusted")
+        _extract_tar_archive(handle, tmp_path)
     before_reuse = prek_cache_markers.snapshot_markers(cache)
 
     reuse = install()

Reply via email to