fix(repositories): narrow return type of repository_merge_base to dict[str, Any] by bibekmhj · Pull Request #3396 · python-gitlab/python-gitlab
Repository navigation
fix(repositories): narrow return type of repository_merge_base to dict[str, Any] - #3396
Open
bibekmhj wants to merge 2 commits into python-gitlab:main from bibekmhj:fix/3390-repository-merge-base-return-type
Open
fix(repositories): narrow return type of repository_merge_base to dict[str, Any] #3396 bibekmhj wants to merge 2 commits into python-gitlab:main from bibekmhj:fix/3390-repository-merge-base-return-type
Conversation
bibekmhj commented May 10, 2026
Copy link Copy Markdown
Fixes #3390 .
The RepositoryMixin.repository_merge_base method was annotated to return
dict[str, Any] | requests.Response, but the call to http_get does not pass
streamed=True or raw=True, and the GitLab /repository/merge_base endpoint
always responds with application/json. Per Gitlab.http_get's implementation
(gitlab/client.py), this means the result is always a parsed dict at runtime,
and the requests.Response branch is unreachable.
This change:
- narrows the return annotation to
dict[str, Any] - adds a
TYPE_CHECKING-guardedassert isinstance(result, dict)to inform
the type-checker, matching the existing pattern used inrepository_raw_blob
andrepository_archive
No runtime behavior changes. Downstream users no longer need to add
cast() or assert isinstance(...) calls before indexing the result.
fix(repositories): narrow return type of repository_merge_base to dic...
56a7604
...t[str, Any]
codecov
Bot
commented
May 10, 2026
·
edited
Loading
Copy link Copy Markdown
Codecov Report✅ All modified and coverable lines are covered by tests. @@ 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.
|
View session
Copilot PR reviewer Copilot
AI
reviewed May 10, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
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 .
docs: fix repository_merge_base docstring to describe merge base, not...
19c45e3
... diffbibekmhj force-pushed the fix/3390-repository-merge-base-return-type branch from
b87775b to
19c45e3
Compare
May 10, 2026 01:32
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment