refactor: migrate from github3.py to PyGithub#509
Merged
Conversation
## 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>
Contributor
There was a problem hiding this comment.
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.pyauth flow with PyGithub'sAuth.AppAuth/GithubIntegration/Auth.Token, removing the manual JWT +requests.postinstallation-token path. - Update
contributors.pyAPI calls (get_organization/get_repos/get_repo/get_commits/get_contributors) and convert date strings todatetimeviadatetime.fromisoformat(); switchcontributions_count→contributions. - 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_count → contributions. |
| 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>
This was referenced Jul 5, 2026
zkoppert
reviewed
Jul 5, 2026
zkoppert
left a comment
Collaborator
There was a problem hiding this comment.
One small dependency-pinning follow-up inline.
Signed-off-by: jmeridth <jmeridth@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Replace
github3.pywithPyGithubfor 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.pylibrary 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/GithubIntegrationflow inauth.pyreplacing the manual JWT + requests patterndatetime.fromisoformat()conversion forget_commits()incontributors.pyReadiness Checklist
Author/Contributor
make lintand fix any issues that you have introducedmake testand ensure you have test coverage for the lines you are introducing