Skip to content

Commit 10b7b83

Browse files
chore: add type-hints to gitlab/cli.py
1 parent 6662252 commit 10b7b83

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

gitlab/cli.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import functools
2222
import re
2323
import sys
24+
from typing import Any, Callable, Dict, Tuple
2425

2526
import gitlab.config
2627

@@ -31,11 +32,13 @@
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)
4043
def wrapped_f(*args, **kwargs):
4144
return f(*args, **kwargs)
@@ -62,22 +65,22 @@ def wrapped_f(*args, **kwargs):
6265
return wrap
6366

6467

65-
def die(msg, e=None):
68+
def die(msg: str, e=None) -> None:
6669
if e:
6770
msg = "%s (%s)" % (msg, e)
6871
sys.stderr.write(msg + "\n")
6972
sys.exit(1)
7073

7174

72-
def what_to_cls(what):
75+
def what_to_cls(what: str) -> str:
7376
return "".join([s.capitalize() for s in what.split("-")])
7477

7578

76-
def cls_to_what(cls):
79+
def cls_to_what(cls) -> str:
7780
return 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:
8184
parser = argparse.ArgumentParser(
8285
add_help=add_help, description="GitLab API Command Line Interface"
8386
)
@@ -148,7 +151,7 @@ def _parse_value(v):
148151
return 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.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy