[click-shell] Add stubs for click-shell (#14578)

This commit is contained in:
Teis Johansen
2025-08-20 11:38:25 +02:00
committed by GitHub
parent 8a56044cd6
commit 673cecca79
6 changed files with 91 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
version = "2.1"
upstream_repository = "https://github.com/clarkperkins/click-shell"
requires = ["click>=8.0.0"]
@@ -0,0 +1,7 @@
from typing import Final
from .core import Shell as Shell, make_click_shell as make_click_shell
from .decorators import shell as shell
__all__ = ["make_click_shell", "shell", "Shell", "__version__"]
__version__: Final[str]
+28
View File
@@ -0,0 +1,28 @@
from cmd import Cmd
from collections.abc import Callable
from typing import Any, ClassVar, TextIO
import click
class ClickCmd(Cmd):
nocommand: ClassVar[str]
def __init__(
self,
ctx: click.Context | None = None,
on_finished: Callable[[click.Context], None] | None = None,
hist_file: str | None = None,
completekey: str = "tab",
stdin: TextIO | None = None,
stdout: TextIO | None = None,
) -> None: ...
def preloop(self) -> None: ...
def postloop(self) -> None: ...
def cmdloop(self, intro: str | None = None) -> None: ...
def get_prompt(self) -> str | None: ...
def emptyline(self) -> bool: ...
def default(self, line: str) -> None: ...
def get_names(self) -> list[str]: ...
def do_help(self, arg: str) -> None: ...
def do_quit(self, arg: str) -> bool: ...
def do_exit(self, arg: str) -> bool: ...
def print_topics(self, header: Any, cmds: list[str] | None, cmdlen: int, maxcol: int) -> None: ...
+10
View File
@@ -0,0 +1,10 @@
import types
from collections.abc import Callable
from typing import Any, Final
import click
PY2: Final = False
def get_method_type(func: Callable[..., Any], obj: object) -> types.MethodType: ...
def get_choices(cli: click.Command, prog_name: str, args: list[str], incomplete: str) -> list[str]: ...
+35
View File
@@ -0,0 +1,35 @@
from collections.abc import Callable
from logging import Logger
from typing import Any
import click
from ._cmd import ClickCmd
logger: Logger
def get_invoke(command: click.Command) -> Callable[[ClickCmd, str], bool]: ...
def get_help(command: click.Command) -> Callable[[ClickCmd], None]: ...
def get_complete(command: click.Command) -> Callable[[ClickCmd, str, str, int, int], list[str]]: ...
class ClickShell(ClickCmd):
def add_command(self, cmd: click.Command, name: str) -> None: ...
def make_click_shell(
ctx: click.Context,
prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
intro: str | None = None,
hist_file: str | None = None,
) -> ClickShell: ...
class Shell(click.Group):
def __init__(
self,
prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
intro: str | None = None,
hist_file: str | None = None,
on_finished: Callable[[click.Context], None] | None = None,
**attrs: Any,
) -> None: ...
def add_command(self, cmd: click.Command, name: str | None = None) -> None: ...
def invoke(self, ctx: click.Context) -> Any: ...
@@ -0,0 +1,8 @@
from collections.abc import Callable
from typing import Any
from click.decorators import _AnyCallable
from .core import Shell
def shell(name: str | None = None, **attrs: Any) -> Callable[[_AnyCallable], Shell]: ...