|
16 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | 17 | """Wrapper for the GitLab API."""
|
18 | 18 |
|
19 |
| -import importlib |
20 | 19 | import time
|
21 | 20 |
|
22 | 21 | import requests
|
@@ -99,7 +98,14 @@ def __init__(
|
99 | 98 | self.pagination = pagination
|
100 | 99 | self.order_by = order_by
|
101 | 100 |
|
102 |
| - objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) |
| 101 | + # We only support v4 API at this time |
| 102 | + if self._api_version not in ("4",): |
| 103 | + raise ModuleNotFoundError(name="gitlab.v%s.objects" % self._api_version) |
| 104 | + # NOTE: We must delay import of gitlab.v4.objects until now or |
| 105 | + # otherwise it will cause circular import errors |
| 106 | + import gitlab.v4.objects |
| 107 | + |
| 108 | + objects = gitlab.v4.objects |
103 | 109 | self._objects = objects
|
104 | 110 |
|
105 | 111 | self.broadcastmessages = objects.BroadcastMessageManager(self)
|
@@ -147,8 +153,14 @@ def __getstate__(self):
|
147 | 153 |
|
148 | 154 | def __setstate__(self, state):
|
149 | 155 | self.__dict__.update(state)
|
150 |
| - objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) |
151 |
| - self._objects = objects |
| 156 | + # We only support v4 API at this time |
| 157 | + if self._api_version not in ("4",): |
| 158 | + raise ModuleNotFoundError(name="gitlab.v%s.objects" % self._api_version) |
| 159 | + # NOTE: We must delay import of gitlab.v4.objects until now or |
| 160 | + # otherwise it will cause circular import errors |
| 161 | + import gitlab.v4.objects |
| 162 | + |
| 163 | + self._objects = gitlab.v4.objects |
152 | 164 |
|
153 | 165 | @property
|
154 | 166 | def url(self):
|
|
0 commit comments