Skip to content

Commit adddbef

Browse files
Testing...
1 parent 0895732 commit adddbef

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

gitlab/cli.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,20 @@ def docs():
158158
sys.exit("Docs parser is only intended for build_sphinx")
159159

160160
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
162165

163-
return _get_parser(cli_module)
166+
# return _get_parser(cli_module)
167+
return _get_parser(gitlab.v4.cli)
164168

165169

166170
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+
167175
if "--version" in sys.argv:
168176
print(gitlab.__version__)
169177
sys.exit(0)
@@ -181,10 +189,15 @@ def main():
181189
parser.print_help()
182190
sys.exit(0)
183191
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)
185197

186198
# 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)
188201
try:
189202
import argcomplete
190203

0 commit comments

Comments
 (0)