refactor: migrate from github3-py to PyGithub#118
Merged
Conversation
## What/Why Replace github3-py with PyGithub (>=2.6.0) as the GitHub API client library, aligning with the measure-innersource migration and consolidating on a single actively maintained library across OSPO actions. ## Proof it works 283 tests pass with 100% code coverage. Black formatting verified clean. Tested locally with `uv run pr_conflict_detector.py`. ## Risk + AI role Medium -- replaces the core GitHub API client across all modules. All source and test code generated by Claude Opus 4.6. ## Review focus - auth.py: retry/timeout now passed via Github constructor kwargs instead of session monkey-patching. Verify the Retry strategy parameters match the original behavior. - Method rename mappings: repository()->get_repo(), pull_request()->get_pull(), issue_comments()->get_issue_comments(), create_comment()->create_issue_comment(), organization()->get_organization(), repositories()->get_repos(). Signed-off-by: jmeridth <jmeridth@gmail.com>
There was a problem hiding this comment.
Pull request overview
Migrates the action’s GitHub API client from github3-py to PyGithub, updating authentication and all API call sites/mocks accordingly to keep PR conflict detection, issue creation, and PR commenting working with the new client.
Changes:
- Replace
github3-pydependency withPyGithub>=2.6.0and update lockfile accordingly. - Refactor authentication to use
github.Auth/Github/GithubIntegrationand pass retry/timeout via constructor kwargs. - Update all production call sites and unit tests for PyGithub method names (
get_repo,get_pull,get_pulls,get_files, etc.) and adjust mypy ignore section.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates locked dependencies to remove github3-py and add pygithub (+ transitive deps). |
| pyproject.toml | Swaps github3-py/pyjwt/cryptography for PyGithub>=2.6.0. |
| auth.py | Refactors authentication + app installation token flow to PyGithub APIs and constructor-based retry/timeout. |
| conflict_detector.py | Migrates verify flow to get_repo()/get_pull() calls. |
| issue_writer.py | Migrates issue lookup to repo.get_issues(...) and updates type-checking import. |
| pr_comment.py | Migrates repo/PR/comment APIs to get_repo()/get_pull()/create_issue_comment(). |
| pr_data.py | Migrates PR listing + changed-files retrieval to get_pulls()/get_files()/get_pull(). |
| pr_conflict_detector.py | Migrates repository enumeration + issue creation repo lookup to PyGithub. |
| .github/linters/.mypy.ini | Updates mypy ignore pattern from github3.* to github.*. |
| test_auth.py | Updates auth tests to patch PyGithub classes and method names. |
| test_conflict_detector.py | Updates mocks for get_repo()/get_pull() usage in verification. |
| test_issue_writer.py | Updates mocks for get_issues() behavior. |
| test_pr_comment_integration.py | Updates mocks for get_repo() call path. |
| test_pr_comment_posting.py | Updates mocks for repo/PR comment APIs (get_pull, get_issue_comments, create_issue_comment). |
| test_pr_conflict_detector_exclude.py | Updates organization/repo mocks to get_organization()/get_repos(). |
| test_pr_conflict_detector_filtering.py | Updates organization/repo mocks to get_organization()/get_repos(). |
| test_pr_conflict_detector_flags.py | Updates organization/repo mocks to get_organization()/get_repos(). |
| test_pr_conflict_detector_main.py | Updates repo/org mocks to get_repo()/get_organization(). |
| test_pr_conflict_detector_repos.py | Updates repo/org iterator tests to get_repo()/get_organization()/get_repos(). |
| test_pr_data.py | Updates PR data mocks to get_pulls()/get_pull()/get_files(). |
Review details
- Files reviewed: 19/20 changed files
- Comments generated: 5
- Review effort level: Low
zkoppert
reviewed
Jun 29, 2026
zkoppert
reviewed
Jun 29, 2026
zkoppert
reviewed
Jun 29, 2026
zkoppert
reviewed
Jun 29, 2026
zkoppert
reviewed
Jun 29, 2026
## What/Why Address reviewer feedback on PR #118: remove custom retry/timeout constants in favor of PyGithub defaults, sanitize trailing slashes on GHE URLs, fix unnecessary split/rejoin patterns for get_repo() calls, and correct docstring/comment references. ## Proof it works All 283 tests pass. Pylint shows only pre-existing warnings. ## Risk + AI role Low -- cleanup changes only. AI-assisted (Claude Opus 4.6). ## Review focus - auth.py retry/timeout removal: verify PyGithub defaults are acceptable - ghe.rstrip("/") placement in both auth functions Signed-off-by: jmeridth <jmeridth@gmail.com>
|
@jmeridth Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
The docstring documented 'str' as the return type but the function signature is 'str | None' and returns None on failure. 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.
What/Why
Replace github3-py with PyGithub (>=2.6.0) as the GitHub API client library, consolidating on a single actively maintained library across OSPO actions.
Proposed Changes
github3-pyforPyGithub>=2.6.0, drop explicitcryptographyandpyjwtdeps (PyGithub handles JWT internally)Auth.Token(),Auth.AppAuth(),GithubIntegration; remove customRETRY_STRATEGY/REQUEST_TIMEOUTconstants and session monkey-patching (_configure_session(),_timeout_wrapper()) in favor of PyGithub's built-in defaults (GithubRetry(total=10),timeout=15)conflict_detector.py,pr_comment.py,pr_data.py,issue_writer.py,pr_conflict_detector.py): Method renames --repository()toget_repo(),pull_request()toget_pull(),pull_requests()toget_pulls(),issue_comments()toget_issue_comments(),create_comment()tocreate_issue_comment(),organization()toget_organization(),repositories()toget_repos(),files()toget_files(),team_by_name()toget_team_by_slug(),members()toget_members()github3.*togithub.*Proof it works
uv run pr_conflict_detector.pyRisk + AI role
Medium -- replaces the core GitHub API client across all modules. All source and test code AI-generated (Claude Opus 4.6).
Review focus
auth.py: Custom retry/timeout removed; PyGithub's built-in defaults (GithubRetry(total=10),timeout=15) handle transient errors and rate limits out of the box. Verify this is acceptable vs the old 5-retry/30s-timeout strategy.Readiness Checklist
Author/Contributor
make lintand fix any issues that you have introducedmake testand ensure you have test coverage for the lines you are introducing