PullRequest

class github.PullRequest.PullRequest

This class represents PullRequests.

The reference can be found here https://docs.github.com/en/rest/reference/pulls

The OpenAPI schema can be found at

  • /components/schemas/pull-request

  • /components/schemas/pull-request-minimal

  • /components/schemas/pull-request-simple

A CompletableGithubObject can be partially initialised (completed=False). Accessing attributes that are not initialized will then trigger a request to complete all attributes.

A partially initialized CompletableGithubObject (completed=False) can be completed via complete(). This requires the url to be given via parameter url or attributes.

With a requester where Requester.is_lazy == True, this CompletableGithubObjects is partially initialized. This requires the url to be given via parameter url or attributes. Any CompletableGithubObject created from this lazy object will be lazy itself if created with parameter url or attributes.

Parameters:
  • requester – requester

  • headers – response headers

  • attributes – attributes to initialize

  • completed – do not update non-initialized attributes when True

  • url – url of this instance, overrides attributes[‘url’]

  • accept – use this accept header when completing this instance

as_issue() Issue
Calls:

GET /repos/{owner}/{repo}/issues/{issue_number}

create_comment(body: str, commit: github.Commit.Commit, path: str, position: int) PullRequestComment
Calls:

POST /repos/{owner}/{repo}/pulls/{pull_number}/comments

create_review_comment(body: str, commit: github.Commit.Commit | str, path: str, line: Opt[int] = NotSet, side: Opt[str] = NotSet, start_line: Opt[int] = NotSet, start_side: Opt[str] = NotSet, in_reply_to: Opt[int] = NotSet, subject_type: Opt[str] = NotSet, as_suggestion: bool = False) PullRequestComment
Calls:

POST /repos/{owner}/{repo}/pulls/{pull_number}/comments

create_review_comment_reply(comment_id: int, body: str) PullRequestComment
Calls:

POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies

create_issue_comment(body: str) IssueComment
Calls:

POST /repos/{owner}/{repo}/issues/{issue_number}/comments

create_review(commit: Opt[github.Commit.Commit] = NotSet, body: Opt[str] = NotSet, event: Opt[str] = NotSet, comments: Opt[list[ReviewComment]] = NotSet) PullRequestReview
Calls:

POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews

create_review_request(reviewers: list[str] | str | _NotSetType = NotSet, team_reviewers: list[str] | str | _NotSetType = NotSet) None
Calls:

POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers

delete_review_request(reviewers: list[str] | str | _NotSetType = NotSet, team_reviewers: list[str] | str | _NotSetType = NotSet) None
Calls:

DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers

edit(title: str | _NotSetType = NotSet, body: str | _NotSetType = NotSet, state: str | _NotSetType = NotSet, base: str | _NotSetType = NotSet, maintainer_can_modify: bool | _NotSetType = NotSet) None
Calls:

PATCH /repos/{owner}/{repo}/pulls/{pull_number}

get_comment(id: int) PullRequestComment
Calls:

GET /repos/{owner}/{repo}/pulls/comments/{comment_id}

get_review_comment(id: int) PullRequestComment
Calls:

GET /repos/{owner}/{repo}/pulls/comments/{comment_id}

get_comments(sort: Opt[str] = NotSet, direction: Opt[str] = NotSet, since: Opt[datetime] = NotSet) PaginatedList[PullRequestComment]

Warning: this only returns review comments. For normal conversation comments, use get_issue_comments.

Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/comments

Parameters:
  • sort – string ‘created’ or ‘updated’

  • direction – string ‘asc’ or ‘desc’

  • since – datetime

get_review_comments(*, sort: Opt[str] = NotSet, direction: Opt[str] = NotSet, since: Opt[datetime] = NotSet) PaginatedList[PullRequestComment]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/comments

Parameters:
  • sort – string ‘created’ or ‘updated’

  • direction – string ‘asc’ or ‘desc’

  • since – datetime

get_single_review_comments(id: int) PaginatedList[PullRequestComment]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments

get_commits() PaginatedList[Commit]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/commits

get_files() PaginatedList[File]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/files

get_issue_comment(id: int) IssueComment
Calls:

GET /repos/{owner}/{repo}/issues/comments/{comment_id}

get_issue_comments() PaginatedList[IssueComment]
Calls:

GET /repos/{owner}/{repo}/issues/{issue_number}/comments

get_issue_events() PaginatedList[IssueEvent]
Calls:

GET /repos/{owner}/{repo}/issues/{issue_number}/events

Return type:

github.PaginatedList.PaginatedList of github.IssueEvent.IssueEvent

get_issue_timeline() PaginatedList[TimelineEvent]

:calls GET /repos/{owner}/{repo}/issues/{issue_number}/timeline :rtype: github.PaginatedList.PaginatedList of github.TimelineEvent

get_review(id: int) PullRequestReview
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}

Parameters:

id – integer

Return type:

github.PullRequestReview.PullRequestReview

get_reviews() PaginatedList[PullRequestReview]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews

Return type:

github.PaginatedList.PaginatedList of github.PullRequestReview.PullRequestReview

get_review_requests() tuple[PaginatedList[NamedUser], PaginatedList[Team]]
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers

Return type:

tuple of github.PaginatedList.PaginatedList of github.NamedUser.NamedUser and of github.PaginatedList.PaginatedList of github.Team.Team

get_labels() PaginatedList[Label]
Calls:

GET /repos/{owner}/{repo}/issues/{issue_number}/labels

add_to_labels(*labels: Label | str) None
Calls:

POST /repos/{owner}/{repo}/issues/{issue_number}/labels

delete_labels() None
Calls:

DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels

remove_from_labels(label: Label | str) None
Calls:

DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}

set_labels(*labels: Label | str) None
Calls:

PUT /repos/{owner}/{repo}/issues/{issue_number}/labels

is_merged() bool
Calls:

GET /repos/{owner}/{repo}/pulls/{pull_number}/merge

restore_branch() GitRef

Convenience function that calls Repository.create_git_ref() :rtype: github.GitRef.GitRef

delete_branch(force: bool = False) None

Convenience function that calls GitRef.delete() :rtype: bool.

enable_automerge(merge_method: str | _NotSetType = 'MERGE', author_email: str | _NotSetType = NotSet, client_mutation_id: str | _NotSetType = NotSet, commit_body: str | _NotSetType = NotSet, commit_headline: str | _NotSetType = NotSet, expected_head_oid: str | _NotSetType = NotSet) dict[str, Any]
Calls:

POST /graphql with a mutation to enable pull request auto merge <https://docs.github.com/en/graphql/reference/mutations#enablepullrequestautomerge>

disable_automerge(client_mutation_id: str | _NotSetType = NotSet) dict[str, Any]
Calls:

POST /graphql with a mutation to disable pull request auto merge <https://docs.github.com/en/graphql/reference/mutations#disablepullrequestautomerge>

merge(commit_message: Opt[str] = NotSet, commit_title: Opt[str] = NotSet, merge_method: Opt[str] = NotSet, sha: Opt[str] = NotSet, delete_branch: bool = False) PullRequestMergeStatus
Calls:

PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge

add_to_assignees(*assignees: NamedUser | str) None
Calls:

POST /repos/{owner}/{repo}/issues/{issue_number}/assignees

remove_from_assignees(*assignees: NamedUser | str) None
Calls:

DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees

update_branch(expected_head_sha: str | _NotSetType = NotSet) bool

:calls PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch

convert_to_draft(client_mutation_id: str | _NotSetType = NotSet) dict[str, Any]
Calls:

POST /graphql to convert pull request to draft <https://docs.github.com/en/graphql/reference/mutations#convertpullrequesttodraft>

mark_ready_for_review(client_mutation_id: str | _NotSetType = NotSet) dict[str, Any]
Calls:

POST /graphql to mark pull request ready for review <https://docs.github.com/en/graphql/reference/mutations#markpullrequestreadyforreview>