Skip to content

Commit

Permalink
feat: add types for click completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mahyarmirrashed committed Sep 21, 2024
1 parent abbe94e commit a8557ce
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
19 changes: 19 additions & 0 deletions stubs/click-completion/click_completion/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
43 changes: 43 additions & 0 deletions stubs/click-completion/click_completion/core.pyi
Original file line number Diff line number Diff line change
@@ -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]: ...
11 changes: 11 additions & 0 deletions stubs/click-completion/click_completion/lib.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
10 changes: 10 additions & 0 deletions stubs/click-completion/click_completion/patch.pyi
Original file line number Diff line number Diff line change
@@ -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: ...

0 comments on commit a8557ce

Please sign in to comment.