Search code examples
pythongitpython

How do you close a pull request in python?


I created a pull request using

github_repo.create_pull(base='master', head=branch_name, title='title')

I can't seem to find how to close one.


Solution

  • Ref the PyGitHub code:

    https://github.com/PyGithub/PyGithub/blob/master/github/PullRequest.py

    See GitHub API, resource "Pulls", Update a pull request for query parameter state

    state string

    Either open, closed, or all to filter by state.

    Default: open

    I'd say you want to update the PR with query-parameter asstate=closed:

    pr = ??? Code to get the PR you want ???
    pr.edit(state="closed")