Skip to content

branch_prs

Actor

Bases: BaseModel

An object representing a committer.

Attributes:

Name Type Description
login str

...

Source code in m/github/graphql/queries/branch_prs.py
class Actor(BaseModel):
    """An object representing a committer."""

    login: str

PullRequest

Bases: CamelModel

A repository pull request.

Attributes:

Name Type Description
closed bool

...

title str

...

number int

...

base_ref_name str

...

mergeable MergeableState

...

merged bool

...

author Actor

...

latest_reviews WithNodes[PullRequestReview]

...

url str

...

Source code in m/github/graphql/queries/branch_prs.py
class PullRequest(CamelModel):
    """A repository pull request."""

    closed: bool
    title: str
    number: int
    base_ref_name: str
    mergeable: MergeableState
    merged: bool
    author: Actor
    latest_reviews: WithNodes[PullRequestReview]
    url: str

PullRequestReview

Bases: BaseModel

A review object for a given pull request.

Attributes:

Name Type Description
author Actor

...

body str

...

state PullRequestReviewState

...

Source code in m/github/graphql/queries/branch_prs.py
class PullRequestReview(BaseModel):
    """A review object for a given pull request."""

    author: Actor
    body: str
    state: PullRequestReviewState

fetch(token, owner, repo, branch)

Retrieve the pr information for the specified branch.

Parameters:

Name Type Description Default
token str

A Github PAT.

required
owner str

The owner of the repo.

required
repo str

The name of the repo.

required
branch str

Name of the branch.

required

Returns:

Type Description
OneOf[Issue, list[PullRequest]]

A list of pull requests connected to the branch or an issue.

Source code in m/github/graphql/queries/branch_prs.py
def fetch(
    token: str,
    owner: str,
    repo: str,
    branch: str,
) -> OneOf[Issue, list[PullRequest]]:
    """Retrieve the pr information for the specified branch.

    Args:
        token: A Github PAT.
        owner: The owner of the repo.
        repo: The name of the repo.
        branch: Name of the branch.

    Returns:
        A list of pull requests connected to the branch or an issue.
    """
    return _fetch(
        lambda raw: TypeAdapter(list[PullRequest]).validate_python(raw),
        token,
        owner,
        repo,
        branch,
    )