21
21
import functools
22
22
import re
23
23
import sys
24
+ from typing import Any , Callable , Dict , Tuple
24
25
25
26
import gitlab .config
26
27
31
32
# action: (mandatory_args, optional_args, in_obj),
32
33
# },
33
34
# }
34
- custom_actions = {}
35
+ custom_actions : Dict [ str , Dict [ str , Tuple [ Tuple [ Any , ...], Tuple [ Any , ...], bool ]]] = {}
35
36
36
37
37
- def register_custom_action (cls_names , mandatory = tuple (), optional = tuple ()):
38
- def wrap (f ):
38
+ def register_custom_action (
39
+ cls_names , mandatory : Tuple [Any , ...] = tuple (), optional : Tuple [Any , ...] = tuple ()
40
+ ) -> Callable :
41
+ def wrap (f ) -> Callable :
39
42
@functools .wraps (f )
40
43
def wrapped_f (* args , ** kwargs ):
41
44
return f (* args , ** kwargs )
@@ -62,22 +65,22 @@ def wrapped_f(*args, **kwargs):
62
65
return wrap
63
66
64
67
65
- def die (msg , e = None ):
68
+ def die (msg : str , e = None ) -> None :
66
69
if e :
67
70
msg = "%s (%s)" % (msg , e )
68
71
sys .stderr .write (msg + "\n " )
69
72
sys .exit (1 )
70
73
71
74
72
- def what_to_cls (what ) :
75
+ def what_to_cls (what : str ) -> str :
73
76
return "" .join ([s .capitalize () for s in what .split ("-" )])
74
77
75
78
76
- def cls_to_what (cls ):
79
+ def cls_to_what (cls ) -> str :
77
80
return camel_re .sub (r"\1-\2" , cls .__name__ ).lower ()
78
81
79
82
80
- def _get_base_parser (add_help = True ):
83
+ def _get_base_parser (add_help : bool = True ) -> argparse . ArgumentParser :
81
84
parser = argparse .ArgumentParser (
82
85
add_help = add_help , description = "GitLab API Command Line Interface"
83
86
)
@@ -148,7 +151,7 @@ def _parse_value(v):
148
151
return v
149
152
150
153
151
- def docs ():
154
+ def docs () -> argparse . ArgumentParser :
152
155
"""
153
156
Provide a statically generated parser for sphinx only, so we don't need
154
157
to provide dummy gitlab config for readthedocs.
0 commit comments