From c5f8fb9d3697d6368bea0c3d2d45ada9f641a8c3 Mon Sep 17 00:00:00 2001 From: Aastha-spec-tech Date: Fri, 29 May 2026 20:45:37 +0530 Subject: [PATCH] fix(license): fix check_license.py symlink traversal crash on Windows (#1360) Signed-off-by: Aastha-spec-tech --- scripts/check_license.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/check_license.py b/scripts/check_license.py index e8991785..d4d31180 100644 --- a/scripts/check_license.py +++ b/scripts/check_license.py @@ -32,6 +32,7 @@ Usage: import argparse import re import sys +import os from datetime import datetime from pathlib import Path @@ -66,10 +67,12 @@ def is_test_file(path: Path) -> bool: def collect_source_files() -> list[Path]: source_files = [] excluded_dirs = {".git", ".github", "venv", "venv3111", "build", "dist", "__pycache__", "tests", "CI"} - for path in REPO_ROOT.rglob("*.py"): - if not any(part in excluded_dirs or part.startswith(".") for part in path.parts): - if not is_test_file(path): - source_files.append(path) + for root, dirs, files in os.walk(REPO_ROOT, followlinks=False): + # In-place modify dirs to avoid traversing excluded directories + dirs[:] = [d for d in dirs if d not in excluded_dirs and not d.startswith(".")] + for file in files: + if file.endswith(".py") and not file.startswith("test_"): + source_files.append(Path(root) / file) return source_files