From 49bebbfd7f8fa5bc673ddad37c18b5f304cb2d49 Mon Sep 17 00:00:00 2001 From: Priya Sundaram Date: Thu, 17 Sep 2026 06:40:11 -0500 Subject: [PATCH 1/2] pr_file_map.py: add ignore_pull_request list, progress passes, dated title - Add module-level ignore_pull_request: list[int]; get_open_prs() filters those PR numbers out (e.g. [123, 456, 789] skips #123, #456, #789). - Drop the redundant DIRECTORY.md comment above DIRECTORY_FILE (the module docstring and render_directory_section already explain it). - Fold the generation datetime into the H1 title: '# Open Pull Request File Map: 16 Sep 2026 at 21:45 UTC'. - Show progress on stderr via other/cheap_progress.py's progress() for the 'First pass' (fetch each PR's files) and 'Second pass' (classify files). --- scripts/pr_file_map.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/pr_file_map.py b/scripts/pr_file_map.py index 254972ed1a9a..d6935100ec58 100644 --- a/scripts/pr_file_map.py +++ b/scripts/pr_file_map.py @@ -49,10 +49,11 @@ from datetime import UTC, datetime from pathlib import Path -# Auto-generated index of the repo. Almost every PR touches it, so a merge -# conflict here is expected and is resolved with "accept both" in the GitHub UI. DIRECTORY_FILE = "DIRECTORY.md" +# Open PRs to skip in the report, e.g. [123, 456, 789] ignores #123, #456, #789. +ignore_pull_request: list[int] = [] + def run_gh(args: list[str]) -> str: try: @@ -113,7 +114,8 @@ def get_open_prs() -> list[dict]: raw = run_gh( ["pr", "list", "--state", "open", "--limit", "1000", "--json", "number,title"] ) - return json.loads(raw) + ignore = set(ignore_pull_request) + return [pr for pr in json.loads(raw) if pr["number"] not in ignore] def get_pr_files(pr_number: int) -> list[str]: @@ -197,6 +199,12 @@ def render_directory_section( def main() -> None: + # Reuse the shared progress() helper from other/cheap_progress.py. It lives at + # the repo root, which is not on sys.path when this script runs directly, so + # add the repo root before importing rather than duplicating the helper here. + sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + from other.cheap_progress import progress + if shutil.which("gh") is None: sys.exit("Error: 'gh' (GitHub CLI) is not installed or not in PATH.") @@ -210,7 +218,7 @@ def main() -> None: pr_to_files: dict[int, list[str]] = {} touch_count = 0 # every (PR, file) pair; a file may be touched by many PRs - for pr in prs: + for pr in progress(prs, desc="First pass"): pr_number = pr["number"] pr_files = get_pr_files(pr_number) pr_to_files[pr_number] = pr_files @@ -232,7 +240,7 @@ def main() -> None: missing: dict[str, list[int]] = {} contested: dict[str, list[int]] = {} - for path, pr_numbers in file_to_prs.items(): + for path, pr_numbers in progress(file_to_prs.items(), desc="Second pass"): deduped = sorted(set(pr_numbers)) target = existing if Path(path).exists() else missing target[path] = deduped @@ -255,9 +263,9 @@ def main() -> None: ) # --- Render GitHub-flavored Markdown --- - print("# Open Pull Request File Map\n") + generated = f"{datetime.now(UTC):%d %b %Y at %H:%M} {UTC}" + print(f"# Open Pull Request File Map: {generated}\n") print(f"- Script: `{script_display_path()}`") - print(f"- Generated: `{datetime.now(UTC):%d %b %Y at %H:%M} {UTC}`") print(f"- Number of PRs: `{pr_count}`") print(f"- File touches (PR x file): `{touch_count}`") print(f"- Distinct files touched: `{distinct_count}`") From 2a56a638b9a0207315fc54cec2bc6411bc526760 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 17 Sep 2026 15:57:08 +0200 Subject: [PATCH 2/2] Change ignore_pull_request from list to set --- scripts/pr_file_map.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/pr_file_map.py b/scripts/pr_file_map.py index d6935100ec58..5435a36f7ae4 100644 --- a/scripts/pr_file_map.py +++ b/scripts/pr_file_map.py @@ -52,7 +52,7 @@ DIRECTORY_FILE = "DIRECTORY.md" # Open PRs to skip in the report, e.g. [123, 456, 789] ignores #123, #456, #789. -ignore_pull_request: list[int] = [] +ignore_pull_request: set[int] = {15105, 15142, 15356} def run_gh(args: list[str]) -> str: @@ -114,7 +114,7 @@ def get_open_prs() -> list[dict]: raw = run_gh( ["pr", "list", "--state", "open", "--limit", "1000", "--json", "number,title"] ) - ignore = set(ignore_pull_request) + ignore = ignore_pull_request return [pr for pr in json.loads(raw) if pr["number"] not in ignore] @@ -199,12 +199,6 @@ def render_directory_section( def main() -> None: - # Reuse the shared progress() helper from other/cheap_progress.py. It lives at - # the repo root, which is not on sys.path when this script runs directly, so - # add the repo root before importing rather than duplicating the helper here. - sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) - from other.cheap_progress import progress - if shutil.which("gh") is None: sys.exit("Error: 'gh' (GitHub CLI) is not installed or not in PATH.") @@ -218,7 +212,7 @@ def main() -> None: pr_to_files: dict[int, list[str]] = {} touch_count = 0 # every (PR, file) pair; a file may be touched by many PRs - for pr in progress(prs, desc="First pass"): + for pr in prs: pr_number = pr["number"] pr_files = get_pr_files(pr_number) pr_to_files[pr_number] = pr_files @@ -240,7 +234,7 @@ def main() -> None: missing: dict[str, list[int]] = {} contested: dict[str, list[int]] = {} - for path, pr_numbers in progress(file_to_prs.items(), desc="Second pass"): + for path, pr_numbers in file_to_prs.items(): deduped = sorted(set(pr_numbers)) target = existing if Path(path).exists() else missing target[path] = deduped