microsoft / microsoft/FluidFramework
[code-simplifier] Simplify pr_review_propose body parsing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 586
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 146
Description
Overview
This PR makes small readability-focused refactors to the recently updated PR review proposal utility script, while preserving behavior.
Changes
.github/scripts/pr_review_propose.py- Centralized reading of stdin vs file paths into a single helper.
- Simplified reviewer preselection and made checkbox parsing de-dupe O(1) while keeping declaration order.
Testing
python -m py_compile .github/scripts/pr_review_propose.py- Manual smoke checks of
build-comment,parse-checkboxes,is-start-checked, andreset-start
Notes
pytest isn’t available in this environment, so the existing test_pr_review_propose.py could not be executed here.
Generated by Code Simplifier · ◷
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/code-simplifier.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
- expires on May 3, 2026, 7:48 AM UTC
[!NOTE]
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branchcode-simplifier/pr-review-propose-simplify-helpers-f6799ea360c26353.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests.
Show patch preview (120 of 120 lines)
From 7d3abd7d89f33b3af0782f8aa3d043a349d61bd4 Mon Sep 17 00:00:00 2001
From: GitHub Copilot <223556219+Copilot@users.noreply.github.com>
Date: Sat, 2 May 2026 07:46:25 +0000
Subject: [PATCH] Simplify PR review proposal script
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
.github/scripts/pr_review_propose.py | 54 +++++++++++++---------------
1 file changed, 25 insertions(+), 29 deletions(-)
diff --git a/.github/scripts/pr_review_propose.py b/.github/scripts/pr_review_propose.py
index 2b1c2ae..3ff7afd 100644
--- a/.github/scripts/pr_review_propose.py
+++ b/.github/scripts/pr_review_propose.py
@@ -54,24 +54,34 @@ _ID_TO_LABEL: dict[str, str] = {r.id: r.label for r in REVIEWERS}
START_LABEL = "Start review"
+def _read_body_file(path: str) -> str:
+ if path == "-":
+ return sys.stdin.read()
+ with open(path, encoding="utf-8") as f:
+ return f.read()
+
+
def get_selected(reviewer_count: int) -> set[str]:
"""Return the reviewer IDs to pre-check for a proposal.
Today this is just the first N by priority. Content-aware selection
(e.g. skipping security on docs-only PRs) can slot in here later.
"""
- priority_ids = [r.id for r in REVIEWERS]
- return set(priority_ids[:reviewer_count])
+ return {r.id for r in REVIEWERS[:reviewer_count]}
def parse_checked_ids(body: str) -> list[str]:
"""Extract checked reviewer IDs (in declaration order) from a comment body."""
found: list[str] = []
+ seen: set[str] = set()
+
for m in re.finditer(r"- \[x\] \*\*(.+?)\*\*", body, re.IGNORECASE):
key = m.group(1).lower()
rid = _LABEL_TO_ID.get(key)
- if rid and rid not in found:
+ if rid and rid not in seen:
+ seen.add(rid)
found.append(rid)
+
return found
@@ -96,12 +106,12 @@ def cmd_build_comment(args: argparse.Namespace) -> None:
selected: set[str] | None = None
if args.from_existing_body:
try:
-
... (truncated)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .github/scripts/pr_review_propose.py and review the proposed helper, reviewer preselection, and checkbox parsing changes described in the patch preview. Run python -m py_compile .github/scripts/pr_review_propose.py and the manual smoke checks for build-comment, parse-checkboxes, is-start-checked, and reset-start; done means behavior is preserved with the simplified implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100