Skip to content

Commit 9c359f8

Browse files
Pull versions from devguide (#32)
1 parent 5e918d4 commit 9c359f8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

needs_backport.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
from __future__ import annotations
2121

2222
import argparse
23+
import json
2324
import os
2425
import subprocess
26+
import urllib.request
2527
from collections import defaultdict
2628
from functools import cache
2729
from typing import Any, TypeAlias
@@ -38,6 +40,21 @@
3840
GITHUB_TOKEN = os.environ["GITHUB_TOOLS_TOKEN"]
3941

4042

43+
@cache
44+
def fetch_active_branches() -> str:
45+
url = "https://raw.githubusercontent.com/python/devguide/main/include/release-cycle.json"
46+
with urllib.request.urlopen(url) as response:
47+
data = json.loads(response.read().decode("utf-8"))
48+
49+
active_versions = []
50+
for version, info in data.items():
51+
status = info.get("status", "")
52+
if status in ("bugfix", "security"):
53+
active_versions.append(version)
54+
55+
return ",".join(active_versions)
56+
57+
4158
@cache
4259
def get_pr_commit(api: GhApi, pull_number: int) -> str:
4360
return api.pulls.get(pull_number=pull_number).merge_commit_sha
@@ -124,7 +141,7 @@ def main() -> None:
124141
parser.add_argument(
125142
"-b",
126143
"--branches",
127-
default="3.13,3.12,3.11,3.10,3.9",
144+
default=fetch_active_branches(),
128145
help="branches to check",
129146
)
130147
parser.add_argument(

0 commit comments

Comments
 (0)