fix(repositories): narrow return type of repository_merge_base to dict[str, Any]#3396
Open
bibekmhj wants to merge 2 commits into
Open
fix(repositories): narrow return type of repository_merge_base to dict[str, Any]#3396bibekmhj wants to merge 2 commits into
bibekmhj wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3396 +/- ##
=======================================
Coverage 95.78% 95.78%
=======================================
Files 100 100
Lines 6170 6171 +1
=======================================
+ Hits 5910 5911 +1
Misses 260 260
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refines the typing of RepositoryMixin.repository_merge_base to reflect its actual runtime behavior when calling GitLab’s /repository/merge_base endpoint, so downstream users can safely index into the returned JSON without extra casts.
Changes:
- Narrow
repository_merge_basereturn type fromdict[str, Any] | requests.Responsetodict[str, Any]. - Add a
TYPE_CHECKING-guardedassert isinstance(result, dict)after thehttp_get()call to help static type-checkers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b87775b to
19c45e3
Compare
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.
Fixes #3390.
The
RepositoryMixin.repository_merge_basemethod was annotated to returndict[str, Any] | requests.Response, but the call tohttp_getdoes not passstreamed=Trueorraw=True, and the GitLab/repository/merge_baseendpointalways responds with
application/json. PerGitlab.http_get's implementation(gitlab/client.py), this means the result is always a parsed
dictat runtime,and the
requests.Responsebranch is unreachable.This change:
dict[str, Any]TYPE_CHECKING-guardedassert isinstance(result, dict)to informthe type-checker, matching the existing pattern used in
repository_raw_bloband
repository_archiveNo runtime behavior changes. Downstream users no longer need to add
cast()orassert isinstance(...)calls before indexing the result.