Skip to content

[release] Add GitHubClient: pull request support#61767

Merged
aslonnie merged 1 commit intomasterfrom
andrew/revup/master/github-client-pulls
Mar 17, 2026
Merged

[release] Add GitHubClient: pull request support#61767
aslonnie merged 1 commit intomasterfrom
andrew/revup/master/github-client-pulls

Conversation

@andrew-anyscale
Copy link
Contributor

Add GitHubPullUser, GitHubPull dataclasses and GitHubRepo.get_pull().
Tests cover successful fetch, 404 error, and auth header verification.

Topic: github-client-pulls
Relative: github-client
Signed-off-by: andrew andrew@anyscale.com

@andrew-anyscale andrew-anyscale requested a review from a team as a code owner March 16, 2026 18:51
@andrew-anyscale
Copy link
Contributor Author

andrew-anyscale commented Mar 16, 2026

Reviews in this chain:
#61767 [release] Add GitHubClient: pull request support
 └#61768 [release] Add GitHubClient: issue support
  └#61710 [release] Replace PyGithub with GitHubClient in ray_release
   └#61711 [ci] Replace PyGithub with GitHubClient in get_contributors.py
    └#61770 [release] Add --no-upgrade to pip-compile args
     └#61712 [release] Remove PyGithub from requirements

@andrew-anyscale
Copy link
Contributor Author

andrew-anyscale commented Mar 16, 2026

# head base diff date summary
0 0a40bf83 bbd8bef0 diff Mar 16 11:51 AM 2 files changed, 78 insertions(+)
1 40ba2ee5 bbd8bef0 diff Mar 16 12:09 PM 1 file changed, 9 insertions(+), 4 deletions(-)
2 d7447e9a 7a62c7fd rebase Mar 16 12:47 PM 0 files changed
3 ae5a4a0e 0ce9d7ae rebase Mar 16 15:17 PM 0 files changed
4 75b1f4ba b86462c1 diff Mar 16 17:22 PM 0 files changed

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds functionality to fetch a single pull request from GitHub by its number. The changes include new dataclasses for the pull request and its author, a new method in GitHubRepo to perform the fetch, and comprehensive tests covering the happy path, error cases, and authentication headers. The implementation is clear and well-tested. I have one suggestion to improve the code structure by encapsulating the object creation logic within the dataclasses themselves, which will enhance maintainability.

Comment on lines +45 to +51
def get_pull(self, number: int) -> GitHubPull:
"""Return a single pull request by number."""
data = self._client._get(f"/repos/{self.full_name}/pulls/{number}")
return GitHubPull(
number=data["number"],
user=GitHubPullUser(login=data["user"]["login"]),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better separation of concerns and maintainability, consider moving the logic for creating GitHubPull and GitHubPullUser instances from the API response dictionary into factory class methods on the dataclasses themselves.

This would look something like this:

@dataclass
class GitHubPullUser:
    login: str

    @classmethod
    def from_dict(cls, data: dict) -> "GitHubPullUser":
        return cls(login=data["login"])

@dataclass
class GitHubPull:
    number: int
    user: GitHubPullUser

    @classmethod
    def from_dict(cls, data: dict) -> "GitHubPull":
        return cls(
            number=data["number"],
            user=GitHubPullUser.from_dict(data["user"])
        )

# In GitHubRepo:
def get_pull(self, number: int) -> GitHubPull:
    """Return a single pull request by number."""
    data = self._client._get(f"/repos/{self.full_name}/pulls/{number}")
    return GitHubPull.from_dict(data)

This pattern makes your dataclasses responsible for their own construction from the raw API data, which is a cleaner design that will be easier to maintain and extend.

@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/master/github-client-pulls branch from 0a40bf8 to 40ba2ee Compare March 16, 2026 19:09
@ray-gardener ray-gardener bot added core Issues that should be addressed in Ray Core devprod labels Mar 16, 2026
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/master/github-client-pulls branch from 40ba2ee to d7447e9 Compare March 16, 2026 19:47
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/master/github-client branch from bbd8bef to 7a62c7f Compare March 16, 2026 19:47
@andrew-anyscale andrew-anyscale added the go add ONLY when ready to merge, run all tests label Mar 16, 2026
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/master/github-client-pulls branch from d7447e9 to ae5a4a0 Compare March 16, 2026 22:17
Base automatically changed from andrew/revup/master/github-client to master March 17, 2026 00:16
Add GitHubPullUser, GitHubPull dataclasses and GitHubRepo.get_pull().
Tests cover successful fetch, 404 error, and auth header verification.

Topic: github-client-pulls
Relative: github-client
Signed-off-by: andrew <andrew@anyscale.com>
@andrew-anyscale andrew-anyscale force-pushed the andrew/revup/master/github-client-pulls branch from ae5a4a0 to 75b1f4b Compare March 17, 2026 00:22
# ---------------------------------------------------------------------------


@responses.activate
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test fixture is really neat~

@aslonnie aslonnie merged commit 8f1c511 into master Mar 17, 2026
6 checks passed
@aslonnie aslonnie deleted the andrew/revup/master/github-client-pulls branch March 17, 2026 07:35
rayhhome pushed a commit to rayhhome/ray that referenced this pull request Mar 17, 2026
Add GitHubPullUser, GitHubPull dataclasses and GitHubRepo.get_pull().
Tests cover successful fetch, 404 error, and auth header verification.

Signed-off-by: andrew <andrew@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core devprod go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants