2121import functools
2222import re
2323import sys
24+ from typing import Any ,Callable ,Dict ,Tuple
2425
2526import gitlab .config
2627
3132# action: (mandatory_args, optional_args, in_obj),
3233# },
3334# }
34- custom_actions = {}
35+ custom_actions : Dict [ str , Dict [ str , Tuple [ Tuple [ Any , ...], Tuple [ Any , ...], bool ]]] = {}
3536
3637
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 :
3942@functools .wraps (f )
4043def wrapped_f (* args ,** kwargs ):
4144return f (* args ,** kwargs )
@@ -62,22 +65,22 @@ def wrapped_f(*args, **kwargs):
6265return wrap
6366
6467
65- def die (msg ,e = None ):
68+ def die (msg : str ,e = None )-> None :
6669if e :
6770msg = "%s (%s)" % (msg ,e )
6871sys .stderr .write (msg + "\n " )
6972sys .exit (1 )
7073
7174
72- def what_to_cls (what ) :
75+ def what_to_cls (what : str ) -> str :
7376return "" .join ([s .capitalize ()for s in what .split ("-" )])
7477
7578
76- def cls_to_what (cls ):
79+ def cls_to_what (cls )-> str :
7780return camel_re .sub (r"\1-\2" ,cls .__name__ ).lower ()
7881
7982
80- def _get_base_parser (add_help = True ):
83+ def _get_base_parser (add_help : bool = True )-> argparse . ArgumentParser :
8184parser = argparse .ArgumentParser (
8285add_help = add_help ,description = "GitLab API Command Line Interface"
8386 )
@@ -148,7 +151,7 @@ def _parse_value(v):
148151return v
149152
150153
151- def docs ():
154+ def docs ()-> argparse . ArgumentParser :
152155"""
153156 Provide a statically generated parser for sphinx only, so we don't need
154157 to provide dummy gitlab config for readthedocs.