fix(repositories): narrow return type of repository_merge_base to dict[str, Any] by bibekmhj · Pull Request #3396 · python-gitlab/python-gitlab
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.