@@ -158,12 +158,20 @@ def docs():
158
158
sys .exit ("Docs parser is only intended for build_sphinx" )
159
159
160
160
parser = _get_base_parser (add_help = False )
161
- cli_module = importlib .import_module ("gitlab.v4.cli" )
161
+ # cli_module = importlib.import_module("gitlab.v4.cli")
162
+ # NOTE: We must delay import of gitlab.v4.cli until now or
163
+ # otherwise it will cause circular import errors
164
+ import gitlab .v4 .cli
162
165
163
- return _get_parser (cli_module )
166
+ # return _get_parser(cli_module)
167
+ return _get_parser (gitlab .v4 .cli )
164
168
165
169
166
170
def main ():
171
+ # NOTE: We must delay import of gitlab.v4.cli until now or
172
+ # otherwise it will cause circular import errors
173
+ import gitlab .v4 .cli
174
+
167
175
if "--version" in sys .argv :
168
176
print (gitlab .__version__ )
169
177
sys .exit (0 )
@@ -181,10 +189,15 @@ def main():
181
189
parser .print_help ()
182
190
sys .exit (0 )
183
191
sys .exit (e )
184
- cli_module = importlib .import_module ("gitlab.v%s.cli" % config .api_version )
192
+ # We only support v4 API at this time
193
+ if config .api_version not in ("4" ,):
194
+ raise ModuleNotFoundError (name = "gitlab.v%s.cli" % self ._api_version )
195
+
196
+ # cli_module = importlib.import_module("gitlab.v%s.cli" % config.api_version)
185
197
186
198
# Now we build the entire set of subcommands and do the complete parsing
187
- parser = _get_parser (cli_module )
199
+ # parser = _get_parser(cli_module)
200
+ parser = _get_parser (gitlab .v4 .cli )
188
201
try :
189
202
import argcomplete
190
203
0 commit comments