INNER CODE UNIT · Python
fetch_all
futo-org/android-keyboard · tools/contributors.py:15
def fetch_all(url: str, params: Dict[str, str] | None = None) -> List[dict]:
"""Paginate until we exhaust the GitHub `Link: rel="next"` header."""
params = dict(params or {}, per_page=100)
items: List[dict] = []
while url:
r = requests.get(url, headers=HEADERS, params=params, timeout=30)
r.raise_for_status()
items.extend(r.json())
# pagination
link = r.headers.get("Link", "")
nxt = re.search(r'<([^>]+)>;\s*rel="next"', link)
url, params = (nxt.group(1), None) if nxt else ("", None)
return items
def merged_pr_authors(owner_repo: str,
label: str | None = None) -> Set[str]:
"""Return the *login* of everyone whose PR is merged. If `label` is given then only looks for the label."""
url = f"{GH_API}/repos/{owner_repo}/pulls"