Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add click-completion Type Stubs #12682

Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ exclude = ["**/test_cases/**/*.py"]
# tell ruff not to flag these as e.g. "unused noqa comments"
external = ["F821", "NQA", "Y"]
select = [
"B", # flake8-bugbear
"FA", # flake8-future-annotations
"I", # isort
"B", # flake8-bugbear
"FA", # flake8-future-annotations
"I", # isort
"RUF", # Ruff-specific and unused-noqa
"UP", # pyupgrade
"UP", # pyupgrade
# Flake8 base rules
"E", # pycodestyle Error
"F", # Pyflakes
Expand Down
7 changes: 2 additions & 5 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"typeshedPath": ".",
"include": [
"stdlib",
"stubs",
],
"include": ["stdlib", "stubs"],
"exclude": [
// test cases use a custom pyrightconfig file
"**/@tests/test_cases",
Expand Down Expand Up @@ -133,5 +130,5 @@
// The name of the self/cls parameter is out of typeshed's control.
"reportSelfClsParameterName": "none",
// Not actionable in typeshed
"reportDeprecated": "none",
"reportDeprecated": "none"
}
3 changes: 3 additions & 0 deletions stubs/click-completion/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "0.5.*"
requires = ["click", "types-click;click<'8'"]
upstream_repository = "https://github.com/click-contrib/click-completion"
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: ...
3 changes: 1 addition & 2 deletions stubs/click-default-group/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version = "1.2.*"
# requires a version of click with a py.typed
requires = ["click>=8.0.0"]
requires = ["click", "types-click;click<'8'"]
upstream_repository = "https://github.com/click-contrib/click-default-group"
Loading