← Winnitude! Search  ·  Reader Mode (1359 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 50 LINKS

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-guarded assert isinstance(result, dict) to inform
    the type-checker, matching the existing pattern used in repository_raw_blob
    and repository_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.
✅ Project coverage is 95.78%. Comparing base (607dddf ) to head (19c45e3 ).
⚠️ Report is 50 commits behind head on main.

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           
Flag Coverage Δ
api_func_v4 83.74% <100.00%> (-0.05%) ⬇️
cli_func_v4 78.72% <33.33%> (-0.02%) ⬇️
unit 90.30% <33.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
gitlab/v4/objects/repositories.py 86.20% <100.00%> (+0.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics : Detect flaky tests, report on failures, and find test suite problems.
JohnVillalovos requested a review from Copilot May 10, 2026 01:04 Copilot started reviewing on behalf of JohnVillalovos May 10, 2026 01:04
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_base return type from dict[str, Any] | requests.Response to dict[str, Any].
  • Add a TYPE_CHECKING-guarded assert isinstance(result, dict) after the http_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
... diff
bibekmhj 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

Labels

None yet

2 participants