Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10b7b83

Browse files
chore: add type-hints to gitlab/cli.py
1 parent6662252 commit10b7b83

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
importfunctools
2222
importre
2323
importsys
24+
fromtypingimportAny,Callable,Dict,Tuple
2425

2526
importgitlab.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-
defregister_custom_action(cls_names,mandatory=tuple(),optional=tuple()):
38-
defwrap(f):
38+
defregister_custom_action(
39+
cls_names,mandatory:Tuple[Any, ...]=tuple(),optional:Tuple[Any, ...]=tuple()
40+
)->Callable:
41+
defwrap(f)->Callable:
3942
@functools.wraps(f)
4043
defwrapped_f(*args,**kwargs):
4144
returnf(*args,**kwargs)
@@ -62,22 +65,22 @@ def wrapped_f(*args, **kwargs):
6265
returnwrap
6366

6467

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

7174

72-
defwhat_to_cls(what):
75+
defwhat_to_cls(what:str)->str:
7376
return"".join([s.capitalize()forsinwhat.split("-")])
7477

7578

76-
defcls_to_what(cls):
79+
defcls_to_what(cls)->str:
7780
returncamel_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
returnv
149152

150153

151-
defdocs():
154+
defdocs()->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)

[8]ページ先頭

©2009-2025 Movatter.jp