Skip to content

refactor: migrate from github3.py to PyGithub#509

Merged
jmeridth merged 3 commits into
mainfrom
migrate-github3-to-pygithub
Jul 6, 2026
Merged

refactor: migrate from github3.py to PyGithub#509
jmeridth merged 3 commits into
mainfrom
migrate-github3-to-pygithub

Conversation

@jmeridth

@jmeridth jmeridth commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Proposed Changes

Replace github3.py with PyGithub for all GitHub API interactions, aligning this repo with the rest of the org (cleanowners, measure-innersource, pr-conflict-detector, evergreen).

What/Why

Standardize on PyGithub across all github-community-projects repos. The github3.py library is less actively maintained and the org has already migrated the other four repos.

Proof it works

68 tests pass with 100% coverage. Pre-commit hooks all pass.

Risk + AI role

Low -- 1:1 API method mapping with no behavioral changes. AI-assisted (Claude Opus 4.6) following established migration patterns from 4 prior org PRs.

Review focus

  • Auth.AppAuth / GithubIntegration flow in auth.py replacing the manual JWT + requests pattern
  • datetime.fromisoformat() conversion for get_commits() in contributors.py

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing

## What/Why

Replace github3.py with PyGithub for GitHub API interactions, aligning
this repo with the rest of the github-community-projects org (cleanowners,
measure-innersource, pr-conflict-detector, evergreen).

## Proof it works

68 tests pass with 100% coverage. pylint 10.00/10, mypy clean, flake8
clean, black formatted, pre-commit hooks all pass.

## Risk + AI role

Low -- 1:1 API method mapping with no behavioral changes. Fully
AI-generated (Claude Opus 4.6) following established migration patterns
from 4 prior org PRs.

## Review focus

- Auth.AppAuth / GithubIntegration flow in auth.py replacing the manual
  JWT + requests pattern
- datetime.fromisoformat() conversion for get_commits() in contributors.py

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth added the Mark Ready When Ready Automatically mark draft PR ready when checks pass label Jul 4, 2026
@jmeridth jmeridth self-assigned this Jul 4, 2026
@jmeridth jmeridth requested a review from Copilot July 4, 2026 20:46
@github-actions github-actions Bot marked this pull request as ready for review July 4, 2026 20:49
@github-actions github-actions Bot requested a review from zkoppert as a code owner July 4, 2026 20:49
@github-actions github-actions Bot removed the Mark Ready When Ready Automatically mark draft PR ready when checks pass label Jul 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the repository's GitHub API layer from github3.py to PyGithub, aligning it with four other org repositories (cleanowners, measure-innersource, pr-conflict-detector, evergreen). The change touches the authentication module and the core contributor-fetching logic, plus corresponding tests, dependency manifests, and linter configuration. It fits into the codebase as an infrastructure/dependency standardization with an intended 1:1 API mapping.

Changes:

  • Replace github3.py auth flow with PyGithub's Auth.AppAuth / GithubIntegration / Auth.Token, removing the manual JWT + requests.post installation-token path.
  • Update contributors.py API calls (get_organization/get_repos/get_repo/get_commits/get_contributors) and convert date strings to datetime via datetime.fromisoformat(); switch contributions_countcontributions.
  • Update dependency pins (pyproject.toml, uv.lock), mypy override (github3.*github.*), and refresh all affected tests.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
auth.py Rewrites auth and installation-token functions to use PyGithub Auth, Github, GithubIntegration, GithubException; drops the redundant post-auth null check.
contributors.py Migrates repo/commit/contributor API calls to PyGithub and converts date strings to datetime for get_commits.
test_auth.py Replaces github3/requests mocks with PyGithub mocks; adds a GHE installation-token test; removes the github3-specific invalid-credentials test.
test_contributors.py Updates mocked method names and asserts datetime args for get_commits; switches contributions_countcontributions.
pyproject.toml Swaps github3-py==4.0.1 dependency for PyGithub>=2.6.0.
uv.lock Regenerated lockfile reflecting pygithub/pynacl additions and github3/dateutil/six/uritemplate removals.
.github/linters/.mypy.ini Updates the ignore-missing-imports override from github3.* to github.*.
.github/linters/.shellcheckrc Removes a trailing whitespace character in a comment.

## What/Why

GithubException only covers HTTP 4xx/5xx responses. Network failures
(DNS, timeout, connection refused) raise requests.exceptions.RequestException
which was not caught, breaking the str | None return contract.

## Proof it works

69 tests pass with 100% coverage. New test covers ConnectionError case.

## Risk + AI role

Low -- broadens exception handling to match the old behavior. AI-generated
(Claude Opus 4.6), fix identified by multi-model code review.

## Review focus

- Exception tuple in auth.py:74 covers both PyGithub and network errors

Signed-off-by: jmeridth <jmeridth@gmail.com>

@zkoppert zkoppert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One small dependency-pinning follow-up inline.

Comment thread pyproject.toml Outdated
Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth requested a review from zkoppert July 5, 2026 18:06

@zkoppert zkoppert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🚀

@jmeridth jmeridth merged commit 7e07777 into main Jul 6, 2026
35 checks passed
@jmeridth jmeridth deleted the migrate-github3-to-pygithub branch July 6, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants