Skip to content

Commit 2ee7f37

Browse files
committed
chore: provide docstrings for gitlab client implementations
1 parent 0b4b4e4 commit 2ee7f37

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

gitlab/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from gitlab import utils
3030
from gitlab.exceptions import GitlabHttpError, GitlabParsingError, on_http_error
3131
from gitlab.types import GitlabList
32+
from gitlab.utils import inherit_docstrings
3233

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

574575

576+
@inherit_docstrings
575577
class Gitlab(BaseGitlab):
576578
_httpx_client_class = httpx.Client
577579

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

783785

786+
@inherit_docstrings
784787
class AsyncGitlab(BaseGitlab):
785788
_httpx_client_class = httpx.AsyncClient
786789

gitlab/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import asyncio
1919
import functools
20+
from inspect import getmembers, isfunction
2021
from urllib.parse import urlparse
2122

2223

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

9596
return wrapped_f
97+
98+
99+
def inherit_docstrings(cls):
100+
"""Inherit docstrings for methods which doesn't have its' own
101+
"""
102+
for name, func in getmembers(cls, isfunction):
103+
if func.__doc__:
104+
continue
105+
106+
for parent in cls.__mro__[1:]:
107+
if hasattr(parent, name):
108+
func.__doc__ = getattr(parent, name).__doc__
109+
break
110+
return cls

0 commit comments

Comments
 (0)