Collapse GitHub integration into one injectable public client and remove hidden factories (closes #311)#442
Merged
Merged
Conversation
GH was a forwarding-only layer: GitHub held a GH instance and delegated every method call to it verbatim, adding no behaviour. Merge GH's body directly into GitHub so there is one public client. - GitHub.__init__ now creates _s and sets auth headers itself - get_default_branch absorbs the combined get_repo_info + REST call that the old GitHub facade provided; GH's (repo: str) overload drops - _get_gh cached factory removed (it was GH-specific and unused outside tests); get_github still exists for the next refactor step - TestGHClass renamed TestGitHubClass; delegates-only tests removed; get_review_threads and resolve_thread gain direct coverage
a018081 to
e46f153
Compare
get_github was a @functools.cache singleton: one shared GitHub instance per token, silently shared across threads and requests. Remove it. - kennel/github.py: drop get_github and functools import - events.py: all seven _gh-or-factory fallbacks now use GitHub() directly - gh_status.py: _get_github default changes from get_github to GitHub (same injectable slot, no caching) - Tests updated: TestGetGithub removed, test_gh_none_uses_get_github now patches kennel.events.GitHub instead of the deleted factory
rhencke
reviewed
Apr 14, 2026
… fallback All events.py public functions now accept `gh: GitHub` as a required positional parameter instead of an optional `_gh=None` keyword with an internal fallback. server.py constructs `gh = type(self)._fn_get_github()` once at the top of `_process_action` and threads it through all call sites.
Drop the _fn_get_github factory class attribute and replace it with a gh instance attribute (GitHub()) set once at class definition time and again in run(). _process_action and _signal_action_error now use self.gh directly instead of calling a factory per request.
Resolves conflicts from #449 (issue picker) landing on main: - kennel/github.py: GH class retained (collapsed-client plan), dropped the now-obsolete GitHub wrapper class from main. New methods from #449 (find_issues with cursor pagination, get_sub_issues, get_issue_node, add_assignee) are already on GH. - tests/test_github.py: dropped wrapper delegation tests for the removed GitHub class; kept the direct GH-class tests for the new methods.
Pass a shared GitHub instance through make_registry, Cmd, and set_gh_status rather than constructing one lazily inside each call site. This eliminates the eager GitHub() at WebhookHandler class body scope that was calling gh auth token at import time and breaking CI collection.
… auth GitHub() called _gh_token() which tried gh CLI in CI (no auth = boom). Add _GitHub=GitHub default param to server.run(), cli.main(), and gh_status.main(), then pass _GitHub=MagicMock in all affected tests.
The task branch in main() called task_main(args[1:]) with no _GitHub argument, so the default-argument-bound GitHub class was used at cli.py load time. Patching kennel.github.GitHub after import had no effect. Import GitHub inside the function body (matching the sync-tasks branch pattern) and forward it via the _GitHub kwarg so test patches intercept the real constructor.
…e globals Add _GitHub injectable to worker.run() and main.main() so tests can pass a mock class directly rather than patching kennel.worker.GitHub or kennel.github.GitHub at the module level.
rhencke
approved these changes
Apr 14, 2026
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.
Collapses the parallel GH and GitHub clients into a single injectable GitHub collaborator, removing cached factories and hidden defaults across events, the webhook handler, the registry, and CLI entry points. Tests now construct fakes directly instead of patching module globals.
Fixes #311.
Work queue
Completed (6)