From dd27494b8fec340d4e0a9f75e418bbf929ca40d6 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Tue, 25 Jul 2023 16:24:40 +0000 Subject: [PATCH] labeler: add --authed-dry-run flag Some data such as author_association is only available to authenticated API users. This helps with testing. --- hacking/pr_labeler/label.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hacking/pr_labeler/label.py b/hacking/pr_labeler/label.py index 4c7523ad67..266e41e94d 100644 --- a/hacking/pr_labeler/label.py +++ b/hacking/pr_labeler/label.py @@ -161,8 +161,14 @@ def cb(): @APP.command(name="pr") -def process_pr(pr_number: int, dry_run: bool = False) -> None: - gclient, repo = get_repo(authed=not dry_run) +def process_pr( + pr_number: int, dry_run: bool = False, authed_dry_run: bool = False +) -> None: + authed = not dry_run + if authed_dry_run: + dry_run = True + authed = True + gclient, repo = get_repo(authed=authed) pr = repo.get_pull(pr_number) ctx = PRLabelerCtx(client=gclient, repo=repo, pr=pr, dry_run=dry_run) if pr.state != "open": @@ -175,8 +181,14 @@ def process_pr(pr_number: int, dry_run: bool = False) -> None: @APP.command(name="issue") -def process_issue(issue_number: int, dry_run: bool = False) -> None: - gclient, repo = get_repo(authed=not dry_run) +def process_issue( + issue_number: int, dry_run: bool = False, authed_dry_run: bool = False +) -> None: + authed = not dry_run + if authed_dry_run: + dry_run = True + authed = True + gclient, repo = get_repo(authed=authed) issue = repo.get_issue(issue_number) ctx = IssueLabelerCtx(client=gclient, repo=repo, issue=issue, dry_run=dry_run) if issue.state != "open":