summaryrefslogtreecommitdiff
path: root/gitlab/cli.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-02-22 22:49:21 +0100
committerGitHub <noreply@github.com>2021-02-22 22:49:21 +0100
commit8c58b071329ec5d37c45647963160ee54cc4048e (patch)
tree9163fd498a5d35a9aa82e7c1efd605f847dd0912 /gitlab/cli.py
parent3aef19c51713bdc7ca0a84752da3ca22329fd4c4 (diff)
parent233b79ed442aac66faf9eb4b0087ea126d6dffc5 (diff)
downloadgitlab-8c58b071329ec5d37c45647963160ee54cc4048e.tar.gz
Merge pull request #1310 from JohnVillalovos/jlvillal/v4_only
chore: explicitly import gitlab.v4.objects/cli
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r--gitlab/cli.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index ff98a4f..d858a74 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -19,7 +19,6 @@
import argparse
import functools
-import importlib
import re
import sys
@@ -158,12 +157,18 @@ def docs():
sys.exit("Docs parser is only intended for build_sphinx")
parser = _get_base_parser(add_help=False)
- cli_module = importlib.import_module("gitlab.v4.cli")
+ # NOTE: We must delay import of gitlab.v4.cli until now or
+ # otherwise it will cause circular import errors
+ import gitlab.v4.cli
- return _get_parser(cli_module)
+ return _get_parser(gitlab.v4.cli)
def main():
+ # NOTE: We must delay import of gitlab.v4.cli until now or
+ # otherwise it will cause circular import errors
+ import gitlab.v4.cli
+
if "--version" in sys.argv:
print(gitlab.__version__)
sys.exit(0)
@@ -181,10 +186,12 @@ def main():
parser.print_help()
sys.exit(0)
sys.exit(e)
- cli_module = importlib.import_module("gitlab.v%s.cli" % config.api_version)
+ # We only support v4 API at this time
+ if config.api_version not in ("4",):
+ raise ModuleNotFoundError(name="gitlab.v%s.cli" % self._api_version)
# Now we build the entire set of subcommands and do the complete parsing
- parser = _get_parser(cli_module)
+ parser = _get_parser(gitlab.v4.cli)
try:
import argcomplete
@@ -229,6 +236,6 @@ def main():
if debug:
gl.enable_debug()
- cli_module.run(gl, what, action, args, verbose, output, fields)
+ gitlab.v4.cli.run(gl, what, action, args, verbose, output, fields)
sys.exit(0)