diff --git a/stubs/click-completion/click_completion/__init__.pyi b/stubs/click-completion/click_completion/__init__.pyi new file mode 100644 index 000000000000..142f4b68aeab --- /dev/null +++ b/stubs/click-completion/click_completion/__init__.pyi @@ -0,0 +1,19 @@ +from enum import Enum +from typing import Any, Callable, Dict, List, Optional, Tuple, Union + +import click +from click import ParamType + +__version__: str +_initialized: bool + +def init(complete_options: bool = False, match_incomplete: Optional[Callable[[str, str], bool]] = None) -> None: ... + +class DocumentedChoice(ParamType): + name: str + def __init__(self, choices: Union[Dict[str, str], Enum]) -> None: ... + def get_metavar(self, param: Any) -> str: ... + def get_missing_message(self, param: Any) -> str: ... + def convert(self, value: str, param: Any, ctx: click.Context) -> Optional[str]: ... + def __repr__(self) -> str: ... + def complete(self, ctx: click.Context, incomplete: str) -> List[Tuple[str, str]]: ... diff --git a/stubs/click-completion/click_completion/core.pyi b/stubs/click-completion/click_completion/core.pyi new file mode 100644 index 000000000000..b09c59894dc1 --- /dev/null +++ b/stubs/click-completion/click_completion/core.pyi @@ -0,0 +1,43 @@ +from enum import Enum +from typing import Callable, Dict, Generator, List, Optional, Tuple + +import click + +shells: Dict[str, str] + +class Shell(Enum): + bash: str + fish: str + zsh: str + powershell: str + +def startswith(string: str, incomplete: str) -> bool: ... + +class CompletionConfiguration: + complete_options: bool + match_complete: Callable[[str, str], bool] + + def __init__(self) -> None: ... + +def match(string: str, incomplete: str) -> bool: ... +def get_choices( + cli: click.Command, prog_name: str, args: List[str], incomplete: str +) -> Generator[Tuple[str, Optional[str]], None, None]: ... +def do_bash_complete(cli: click.Command, prog_name: str) -> bool: ... +def do_fish_complete(cli: click.Command, prog_name: str) -> bool: ... +def do_zsh_complete(cli: click.Command, prog_name: str) -> bool: ... +def do_powershell_complete(cli: click.Command, prog_name: str) -> bool: ... +def get_code( + shell: Optional[Shell] = None, + prog_name: Optional[str] = None, + env_name: Optional[str] = None, + extra_env: Optional[Dict[str, str]] = None, +) -> str: ... +def install( + shell: Optional[Shell] = None, + prog_name: Optional[str] = None, + env_name: Optional[str] = None, + path: Optional[str] = None, + append: Optional[bool] = None, + extra_env: Optional[Dict[str, str]] = None, +) -> Tuple[Shell, str]: ... diff --git a/stubs/click-completion/click_completion/lib.pyi b/stubs/click-completion/click_completion/lib.pyi new file mode 100644 index 000000000000..fa67556250e6 --- /dev/null +++ b/stubs/click-completion/click_completion/lib.pyi @@ -0,0 +1,11 @@ +from typing import List, Optional + +import click + +def single_quote(s: str) -> str: ... +def double_quote(s: str) -> str: ... +def resolve_ctx( + cli: click.Command, prog_name: str, args: List[str], resilient_parsing: bool = True +) -> Optional[click.core.Context]: ... +def split_args(line: str) -> List[str]: ... +def get_auto_shell() -> str: ... diff --git a/stubs/click-completion/click_completion/patch.pyi b/stubs/click-completion/click_completion/patch.pyi new file mode 100644 index 000000000000..3c9bc859c881 --- /dev/null +++ b/stubs/click-completion/click_completion/patch.pyi @@ -0,0 +1,10 @@ +from typing import List, Optional, Tuple + +import click + +def param_type_complete(self: click.ParamType, ctx: click.core.Context, incomplete: str) -> List[Tuple[str, Optional[str]]]: ... +def choice_complete(self: click.Choice, ctx: click.core.Context, incomplete: str) -> List[Tuple[str, Optional[str]]]: ... +def multicommand_get_command_short_help(self: click.MultiCommand, ctx: click.Context, cmd_name: str) -> str: ... +def multicommand_get_command_hidden(self: click.MultiCommand, ctx: click.Context, cmd_name: str) -> bool: ... +def _shellcomplete(cli: click.Command, prog_name: str, complete_var: Optional[str] = None) -> None: ... +def patch() -> None: ...