Skip to content

Instantly share code, notes, and snippets.

@jb3
Created February 3, 2020 18:28
Show Gist options
  • Save jb3/a94f2ca1be3bec72f9f5b4e27436b236 to your computer and use it in GitHub Desktop.
Save jb3/a94f2ca1be3bec72f9f5b4e27436b236 to your computer and use it in GitHub Desktop.
import urllib.parse
from typing import Union
import httpx
with open("./github.access") as token_file:
token = token_file.read().strip()
def get(route: str, arguments: dict = {}) -> Union[dict, list]:
return httpx.get(
f"https://api.github.com/{route}?{urllib.parse.urlencode(arguments)}",
headers={
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github.v3+json"
}
).json()
username = get("user")["login"]
pull_requests = get("search/issues", {
"q": f"is:open is:pr review-requested:{username} archived:false"
})
print("Requiring your review:")
for pr in pull_requests["items"]:
data = get("/".join(pr["pull_request"]["url"].split("/")[3:]) + "/requested_reviewers")
actual_users = data["users"]
for user in actual_users:
if username == user["login"]:
print(f'\t{pr["title"]} - {pr["pull_request"]["html_url"]}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment