summaryrefslogtreecommitdiff
path: root/gitlab/cli.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-02-25 10:28:05 -0800
committerJohn L. Villalovos <john@sodarock.com>2021-02-25 21:23:32 -0800
commit10b7b836d31fbe36a7096454287004b46a7799dd (patch)
treea6df3c7f7a79647ae79b072b902bcc0308df0ac8 /gitlab/cli.py
parent666225221deec06014d5ccff46d1c21d5828c977 (diff)
downloadgitlab-10b7b836d31fbe36a7096454287004b46a7799dd.tar.gz
chore: add type-hints to gitlab/cli.py
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r--gitlab/cli.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index 485bbbb..1e98a38 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -21,6 +21,7 @@ import argparse
import functools
import re
import sys
+from typing import Any, Callable, Dict, Tuple
import gitlab.config
@@ -31,11 +32,13 @@ camel_re = re.compile("(.)([A-Z])")
# action: (mandatory_args, optional_args, in_obj),
# },
# }
-custom_actions = {}
+custom_actions: Dict[str, Dict[str, Tuple[Tuple[Any, ...], Tuple[Any, ...], bool]]] = {}
-def register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):
- def wrap(f):
+def register_custom_action(
+ cls_names, mandatory: Tuple[Any, ...] = tuple(), optional: Tuple[Any, ...] = tuple()
+) -> Callable:
+ def wrap(f) -> Callable:
@functools.wraps(f)
def wrapped_f(*args, **kwargs):
return f(*args, **kwargs)
@@ -62,22 +65,22 @@ def register_custom_action(cls_names, mandatory=tuple(), optional=tuple()):
return wrap
-def die(msg, e=None):
+def die(msg: str, e=None) -> None:
if e:
msg = "%s (%s)" % (msg, e)
sys.stderr.write(msg + "\n")
sys.exit(1)
-def what_to_cls(what):
+def what_to_cls(what: str) -> str:
return "".join([s.capitalize() for s in what.split("-")])
-def cls_to_what(cls):
+def cls_to_what(cls) -> str:
return camel_re.sub(r"\1-\2", cls.__name__).lower()
-def _get_base_parser(add_help=True):
+def _get_base_parser(add_help: bool = True) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
add_help=add_help, description="GitLab API Command Line Interface"
)
@@ -148,7 +151,7 @@ def _parse_value(v):
return v
-def docs():
+def docs() -> argparse.ArgumentParser:
"""
Provide a statically generated parser for sphinx only, so we don't need
to provide dummy gitlab config for readthedocs.