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

chore: add type-hints to gitlab/cli.py#1334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intopython-gitlab:masterfromJohnVillalovos:jlvillal/mypy_cli
Feb 26, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletionsgitlab/cli.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,7 @@
import functools
import re
import sys
from typing import Any, Callable, Dict, Tuple

import gitlab.config

Expand All@@ -31,11 +32,13 @@
# 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)
Expand All@@ -62,22 +65,22 @@ def wrapped_f(*args, **kwargs):
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"
)
Expand DownExpand Up@@ -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.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp