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() → github.Issue.Issue
Calls

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

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

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

create_review_comment(body: str, commit: github.Commit.Commit, 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/{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/{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/{number}/reviews

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

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

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

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

edit(title: Union[str, github.GithubObject._NotSetType] = NotSet, body: Union[str, github.GithubObject._NotSetType] = NotSet, state: Union[str, github.GithubObject._NotSetType] = NotSet, base: Union[str, github.GithubObject._NotSetType] = NotSet, maintainer_can_modify: Union[bool, github.GithubObject._NotSetType] = NotSet) → None
Calls

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

get_comment(id: int) → PullRequestComment
Calls

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

get_review_comment(id: int) → PullRequestComment
Calls

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

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/{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/{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/{number}/review/{id}/comments

get_commits() → PaginatedList[Commit]
Calls

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

get_files() → PaginatedList[File]
Calls

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

get_issue_comment(id: int) → IssueComment
Calls

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

get_issue_comments() → PaginatedList[IssueComment]
Calls

GET /repos/{owner}/{repo}/issues/{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_review(id: int) → PullRequestReview
Calls

GET /repos/{owner}/{repo}/pulls/{number}/reviews/{id}

Parameters

id – integer

Return type

github.PullRequestReview.PullRequestReview

get_reviews() → PaginatedList[PullRequestReview]
Calls

GET /repos/{owner}/{repo}/pulls/{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/{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/{number}/labels

add_to_labels(*labels: github.Label.Label | str) → None
Calls

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

delete_labels() → None
Calls

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

remove_from_labels(label: github.Label.Label | str) → None
Calls

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

set_labels(*labels: github.Label.Label | str) → None
Calls

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

is_merged() → bool
Calls

GET /repos/{owner}/{repo}/pulls/{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: Opt[str] = 'MERGE', author_email: Opt[str] = NotSet, client_mutation_id: Opt[str] = NotSet, commit_body: Opt[str] = NotSet, commit_headline: Opt[str] = NotSet, expected_head_oid: Opt[str] = 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: Opt[str] = 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/{number}/merge

add_to_assignees(*assignees: github.NamedUser.NamedUser | str) → None
Calls

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

remove_from_assignees(*assignees: github.NamedUser.NamedUser | str) → None
Calls

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

update_branch(expected_head_sha: Union[str, github.GithubObject._NotSetType] = NotSet) → bool

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

convert_to_draft(client_mutation_id: Opt[str] = 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: Opt[str] = NotSet) → dict[str, Any]
Calls

POST /graphql to mark pull request ready for review

<https://docs.github.com/en/graphql/reference/mutations#markpullrequestreadyforreview>