refactor: port from github3.py to PyGithub#434
Merged
Conversation
## What/Why Replace github3.py with PyGithub for GitHub API interactions, aligning this repo with the same library used across other OSPO projects (pr-conflict-detector, measure-innersource). ## Proof it works 73 tests pass with 100% coverage. Pylint 10.00/10, mypy clean, flake8 clean, black formatted, isort clean. ## Risk + AI role Low -- 1:1 API migration with no behavioral changes. All code AI-generated (Claude Opus 4.6) with human review. ## Review focus - Auth flow changes in auth.py (App auth now uses Auth.AppAuth + get_installation_auth instead of login_as_app_installation) - Large file blob handling in cleanowners.py (base64 decode path) Signed-off-by: jmeridth <jmeridth@gmail.com>
zkoppert
reviewed
Jul 3, 2026
zkoppert
left a comment
Collaborator
There was a problem hiding this comment.
Multi-model review of the github3 to PyGithub migration below (Opus, GPT-5.3-Codex, GPT-5.4, all findings verified in the repo venv). Two verified Highs where the PyGithub object types differ from github3: has_in_members needs a NamedUser rather than a login string, and the large-file content is None guard never fires. I also flagged the exception-scope broadening in the read paths. Details inline.
- Resolve username to NamedUser before has_in_members() call - Fix large file detection: check encoding=="none" instead of content is None - Narrow except clauses to UnknownObjectException for 404-only semantics - Log exception status/data in PR-creation error messages - Fix import order (third-party before first-party) Signed-off-by: jmeridth <jmeridth@gmail.com>
zkoppert
reviewed
Jul 3, 2026
There was a problem hiding this comment.
Pull request overview
This PR migrates GitHub API usage from github3.py to PyGithub to align this action with other OSPO/community projects, updating authentication, repository/file operations, and test mocks accordingly.
Changes:
- Swap runtime dependency from
github3-pytoPyGithuband adjust lockfile/dev-deps. - Update GitHub API calls in
cleanowners.py(org lookup, repo iteration, content updates, large-file blob handling, membership checks). - Refactor auth flow in
auth.pyto useAuth.TokenandAuth.AppAuth+ installation auth; update tests and mypy ignore rules forgithub.*.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Replaces github3-py with pygithub and updates the resolved dependency graph. |
pyproject.toml |
Updates declared dependencies to use PyGithub instead of github3-py (and removes some direct pins/dev deps). |
cleanowners.py |
Ports GitHub API interactions to PyGithub equivalents (refs, contents, blobs, membership checks, exceptions). |
auth.py |
Reimplements PAT/App authentication using PyGithub Auth helpers and Github client initialization. |
test_auth.py |
Updates unit tests to patch PyGithub classes and validate new auth construction behavior. |
test_cleanowners.py |
Updates mocks/expectations for PyGithub repo/org/content APIs and exception types. |
.github/linters/.mypy.ini |
Adjusts mypy ignore rule from github3.* to github.*. |
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 8
- Review effort level: Low
- Wrap get_user() + has_in_members() in try/except for deleted accounts - Strip trailing slash from GHE URL to prevent double slashes - Fix test_auth.py type mismatches: use None/int instead of empty strings 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
Port from
github3.pytoPyGithubfor GitHub API interactions, aligning this repo with the same library used across other community projects (pr-conflict-detector, measure-innersource).What/Why
github3.pyis being replaced withPyGithubacross OSPO projects for consistency. PyGithub handles retry/timeout internally, removing the need for therequestsdependency.Proof it works
73 tests pass with 100% coverage.
Risk + AI role
Low -- 1:1 API migration with no behavioral changes. AI-assisted (Claude Opus 4.6) with human review.
Review focus
auth.py-- App auth now usesAuth.AppAuth+get_installation_authinstead oflogin_as_app_installationcleanowners.py-- base64 decode path viaget_git_blobReadiness Checklist
Author/Contributor
make lintand fix any issues that you have introducedmake testand ensure you have test coverage for the lines you are introducing