diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-02-22 22:49:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 22:49:21 +0100 |
commit | 8c58b071329ec5d37c45647963160ee54cc4048e (patch) | |
tree | 9163fd498a5d35a9aa82e7c1efd605f847dd0912 /gitlab/client.py | |
parent | 3aef19c51713bdc7ca0a84752da3ca22329fd4c4 (diff) | |
parent | 233b79ed442aac66faf9eb4b0087ea126d6dffc5 (diff) | |
download | gitlab-8c58b071329ec5d37c45647963160ee54cc4048e.tar.gz |
Merge pull request #1310 from JohnVillalovos/jlvillal/v4_only
chore: explicitly import gitlab.v4.objects/cli
Diffstat (limited to 'gitlab/client.py')
-rw-r--r-- | gitlab/client.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index dbfc834..6d0401d 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -16,7 +16,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. """Wrapper for the GitLab API.""" -import importlib import time import requests @@ -99,7 +98,14 @@ class Gitlab(object): self.pagination = pagination self.order_by = order_by - objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) + # We only support v4 API at this time + if self._api_version not in ("4",): + raise ModuleNotFoundError(name="gitlab.v%s.objects" % self._api_version) + # NOTE: We must delay import of gitlab.v4.objects until now or + # otherwise it will cause circular import errors + import gitlab.v4.objects + + objects = gitlab.v4.objects self._objects = objects self.broadcastmessages = objects.BroadcastMessageManager(self) @@ -147,8 +153,14 @@ class Gitlab(object): def __setstate__(self, state): self.__dict__.update(state) - objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) - self._objects = objects + # We only support v4 API at this time + if self._api_version not in ("4",): + raise ModuleNotFoundError(name="gitlab.v%s.objects" % self._api_version) + # NOTE: We must delay import of gitlab.v4.objects until now or + # otherwise it will cause circular import errors + import gitlab.v4.objects + + self._objects = gitlab.v4.objects @property def url(self): |