Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/GitHub/GitHub_List_closed_pull_requests.ipynb
2973 views
Kernel: Python 3

GitHub.png

GitHub - List closed pull requests

Give Feedback | Bug report

Tags: #github #pygithub #closedpr #repo #api #python

Last update: 2023-04-12 (Created: 2023-03-09)

Description: This notebook list closed pull requests from a repository name using pygithub library.

Input

Import libraries

import os import json from github import Github import naas

Setup Variables

token = naas.secret.get("GITHUB_TOKEN") or "YOUR_TOKEN" repo_name = "jupyter-naas/awesome-notebooks"

Model

List pull requests

Using the Github class from the github library, we can connect to the GitHub API and get the closed PR from a given repository.

# Connect to the GitHub API g = Github(token) # Get the repository repo = g.get_repo(repo_name) # Get the closed PR pull_requests = repo.get_pulls(state="closed")

Output

Display result

# Print the closed PR print("✅ Pull Requests fetched:", pull_requests.totalCount) for index, pr in enumerate(pull_requests): print(json.dumps(pr.raw_data, indent=4)) break