From 3710a03236afc2a724ba6762ed2a03f316039cd2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:54:17 +0200 Subject: [PATCH] Add token name to CLI args --- potential_closeable_prs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/potential_closeable_prs.py b/potential_closeable_prs.py index b8bef9c..dced25b 100644 --- a/potential_closeable_prs.py +++ b/potential_closeable_prs.py @@ -23,9 +23,6 @@ Issue: TypeAlias = dict[str, Any] -GITHUB_TOKEN = os.environ["GITHUB_TOOLS_TOKEN"] - - def check_issue(api: GhApi, issue: Issue) -> list[Issue]: """ Look for a chunk like this, collect the PRs: @@ -121,8 +118,9 @@ def check_issues( number: int = 100, author: str | None = None, sort_by: str = "newest", + token: str = "GITHUB_TOOLS_TOKEN", ) -> list[Issue]: - api = GhApi(owner="python", repo="cpython", token=GITHUB_TOKEN) + api = GhApi(owner="python", repo="cpython", token=os.environ[token]) sort, direction = sort_by_to_sort_and_direction(sort_by) candidates = [] @@ -179,13 +177,18 @@ def main() -> None: ), help="Sort by", ) + parser.add_argument( + "-t", "--token", default="GITHUB_TOOLS_TOKEN", help="Token environment variable" + ) parser.add_argument( "-x", "--dry-run", action="store_true", help="show but don't open issues" ) args = parser.parse_args() # Find - candidates = check_issues(args.start, args.number, args.author, args.sort) + candidates = check_issues( + args.start, args.number, args.author, args.sort, args.token + ) # Report print()