Skip to content

Commit

Permalink
Merge pull request #148 from scop/type-hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Jul 31, 2023
2 parents ea43eb8 + ebedce0 commit 2a7af72
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shtab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def wrapper(func):
return wrapper


def get_completer(shell):
def get_completer(shell: str):
try:
return _SUPPORTED_COMPLETERS[shell]
except KeyError:
Expand Down Expand Up @@ -123,7 +123,7 @@ class Required:
DIR = DIRECTORY = [Choice("directory", True)]


def complete2pattern(opt_complete, shell, choice_type2fn) -> bool:
def complete2pattern(opt_complete, shell: str, choice_type2fn) -> str:
return (opt_complete.get(shell, "")
if isinstance(opt_complete, dict) else choice_type2fn[opt_complete])

Expand Down Expand Up @@ -772,7 +772,7 @@ def recurse_parser(cparser, positional_idx, requirements=None):


def complete(parser: ArgumentParser, shell: str = "bash", root_prefix: Opt[str] = None,
preamble: Union[str, Dict] = "", choice_functions: Opt[Any] = None) -> str:
preamble: Union[str, Dict[str, str]] = "", choice_functions: Opt[Any] = None) -> str:
"""
shell:
bash/zsh/tcsh
Expand All @@ -798,7 +798,7 @@ def complete(parser: ArgumentParser, shell: str = "bash", root_prefix: Opt[str]
)


def completion_action(parent: Opt[ArgumentParser] = None, preamble: Union[str, Dict] = ""):
def completion_action(parent: Opt[ArgumentParser] = None, preamble: Union[str, Dict[str, str]] = ""):
class PrintCompletionAction(_ShtabPrintCompletionAction):
def __call__(self, parser, namespace, values, option_string=None):
print(complete(parent or parser, values, preamble=preamble))
Expand All @@ -812,7 +812,7 @@ def add_argument_to(
option_string: Union[str, List[str]] = "--print-completion",
help: str = "print shell completion script",
parent: Opt[ArgumentParser] = None,
preamble: Union[str, Dict] = "",
preamble: Union[str, Dict[str, str]] = "",
):
"""
option_string:
Expand Down

0 comments on commit 2a7af72

Please sign in to comment.