Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gitlab/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from gitlab import utils
from gitlab.exceptions import GitlabHttpError, GitlabParsingError, on_http_error
from gitlab.types import GitlabList
from gitlab.utils import inherit_docstrings

REDIRECT_MSG = (
"python-gitlab detected an http to https redirection. You "
Expand Down Expand Up @@ -572,6 +573,7 @@ def search(self, scope, search, **kwargs):
return self.http_list("/search", query_data=data, **kwargs)


@inherit_docstrings
class Gitlab(BaseGitlab):
_httpx_client_class = httpx.Client

Expand Down Expand Up @@ -781,6 +783,7 @@ def http_put(self, path, query_data=None, post_data=None, files=None, **kwargs):
raise GitlabParsingError(error_message="Failed to parse the server message")


@inherit_docstrings
class AsyncGitlab(BaseGitlab):
_httpx_client_class = httpx.AsyncClient

Expand Down
15 changes: 15 additions & 0 deletions gitlab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import asyncio
import functools
from inspect import getmembers, isfunction
from urllib.parse import urlparse


Expand Down Expand Up @@ -93,3 +94,17 @@ def wrapped_f(self, obj, *args, **kwargs):
return f(self, obj, *args, **kwargs)

return wrapped_f


def inherit_docstrings(cls):
"""Inherit docstrings for methods which doesn't have its' own
"""
for name, func in getmembers(cls, isfunction):
if func.__doc__:
continue

for parent in cls.__mro__[1:]:
if hasattr(parent, name):
func.__doc__ = getattr(parent, name).__doc__
break
return cls