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

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


The following commit(s) were added to refs/heads/v3-2-test by this push:
     new 8cbe7b9c4a1 [v3-2-test] Speed up cleanup_python_generated_files by 
skipping irrelevant dirs (#64927) (#64930)
8cbe7b9c4a1 is described below

commit 8cbe7b9c4a18cf93c751fbdd0618ac92e70c20f4
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Apr 9 01:28:00 2026 +0300

    [v3-2-test] Speed up cleanup_python_generated_files by skipping irrelevant 
dirs (#64927) (#64930)
    
    Replace two rglob calls with a single os.walk that prunes node_modules
    and hidden directories (e.g. .git, .venv) in-place, avoiding unnecessary
    traversal of large directory trees that never contain relevant .pyc files.
    (cherry picked from commit 27258d567887a93f43af25a9d79d773198751bd9)
    
    Co-authored-by: Jarek Potiuk <[email protected]>
---
 dev/breeze/src/airflow_breeze/utils/path_utils.py | 36 +++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/path_utils.py 
b/dev/breeze/src/airflow_breeze/utils/path_utils.py
index 03877d64761..7f2625a0bcc 100644
--- a/dev/breeze/src/airflow_breeze/utils/path_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/path_utils.py
@@ -418,22 +418,26 @@ def cleanup_python_generated_files():
     if get_verbose():
         console_print("[info]Cleaning .pyc and __pycache__")
     permission_errors = []
-    for path in AIRFLOW_ROOT_PATH.rglob("*.pyc"):
-        try:
-            path.unlink()
-        except FileNotFoundError:
-            # File has been removed in the meantime.
-            pass
-        except PermissionError:
-            permission_errors.append(path)
-    for path in AIRFLOW_ROOT_PATH.rglob("__pycache__"):
-        try:
-            shutil.rmtree(path)
-        except FileNotFoundError:
-            # File has been removed in the meantime.
-            pass
-        except PermissionError:
-            permission_errors.append(path)
+    for dirpath, dirnames, filenames in os.walk(AIRFLOW_ROOT_PATH):
+        # Skip node_modules and hidden directories (.*) — modify in place to 
prune os.walk
+        dirnames[:] = [d for d in dirnames if d != "node_modules" and not 
d.startswith(".")]
+        for filename in filenames:
+            if filename.endswith(".pyc"):
+                path = Path(dirpath) / filename
+                try:
+                    path.unlink()
+                except FileNotFoundError:
+                    pass
+                except PermissionError:
+                    permission_errors.append(path)
+        if Path(dirpath).name == "__pycache__":
+            try:
+                shutil.rmtree(dirpath)
+            except FileNotFoundError:
+                pass
+            except PermissionError:
+                permission_errors.append(Path(dirpath))
+            dirnames.clear()
     if permission_errors:
         if platform.uname().system.lower() == "linux":
             console_print("[warning]There were files that you could not 
clean-up:\n")

Reply via email to