Skip to content

Commit 673cecc

Browse files
authored
[click-shell] Add stubs for click-shell (#14578)
1 parent 8a56044 commit 673cecc

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

stubs/click-shell/METADATA.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version = "2.1"
2+
upstream_repository = "https://github.com/clarkperkins/click-shell"
3+
requires = ["click>=8.0.0"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import Final
2+
3+
from .core import Shell as Shell, make_click_shell as make_click_shell
4+
from .decorators import shell as shell
5+
6+
__all__ = ["make_click_shell", "shell", "Shell", "__version__"]
7+
__version__: Final[str]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from cmd import Cmd
2+
from collections.abc import Callable
3+
from typing import Any, ClassVar, TextIO
4+
5+
import click
6+
7+
class ClickCmd(Cmd):
8+
nocommand: ClassVar[str]
9+
def __init__(
10+
self,
11+
ctx: click.Context | None = None,
12+
on_finished: Callable[[click.Context], None] | None = None,
13+
hist_file: str | None = None,
14+
completekey: str = "tab",
15+
stdin: TextIO | None = None,
16+
stdout: TextIO | None = None,
17+
) -> None: ...
18+
def preloop(self) -> None: ...
19+
def postloop(self) -> None: ...
20+
def cmdloop(self, intro: str | None = None) -> None: ...
21+
def get_prompt(self) -> str | None: ...
22+
def emptyline(self) -> bool: ...
23+
def default(self, line: str) -> None: ...
24+
def get_names(self) -> list[str]: ...
25+
def do_help(self, arg: str) -> None: ...
26+
def do_quit(self, arg: str) -> bool: ...
27+
def do_exit(self, arg: str) -> bool: ...
28+
def print_topics(self, header: Any, cmds: list[str] | None, cmdlen: int, maxcol: int) -> None: ...
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import types
2+
from collections.abc import Callable
3+
from typing import Any, Final
4+
5+
import click
6+
7+
PY2: Final = False
8+
9+
def get_method_type(func: Callable[..., Any], obj: object) -> types.MethodType: ...
10+
def get_choices(cli: click.Command, prog_name: str, args: list[str], incomplete: str) -> list[str]: ...
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from collections.abc import Callable
2+
from logging import Logger
3+
from typing import Any
4+
5+
import click
6+
7+
from ._cmd import ClickCmd
8+
9+
logger: Logger
10+
11+
def get_invoke(command: click.Command) -> Callable[[ClickCmd, str], bool]: ...
12+
def get_help(command: click.Command) -> Callable[[ClickCmd], None]: ...
13+
def get_complete(command: click.Command) -> Callable[[ClickCmd, str, str, int, int], list[str]]: ...
14+
15+
class ClickShell(ClickCmd):
16+
def add_command(self, cmd: click.Command, name: str) -> None: ...
17+
18+
def make_click_shell(
19+
ctx: click.Context,
20+
prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
21+
intro: str | None = None,
22+
hist_file: str | None = None,
23+
) -> ClickShell: ...
24+
25+
class Shell(click.Group):
26+
def __init__(
27+
self,
28+
prompt: str | Callable[[], str] | Callable[[click.Context, str], str] | None = None,
29+
intro: str | None = None,
30+
hist_file: str | None = None,
31+
on_finished: Callable[[click.Context], None] | None = None,
32+
**attrs: Any,
33+
) -> None: ...
34+
def add_command(self, cmd: click.Command, name: str | None = None) -> None: ...
35+
def invoke(self, ctx: click.Context) -> Any: ...
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from collections.abc import Callable
2+
from typing import Any
3+
4+
from click.decorators import _AnyCallable
5+
6+
from .core import Shell
7+
8+
def shell(name: str | None = None, **attrs: Any) -> Callable[[_AnyCallable], Shell]: ...

0 commit comments

Comments
 (0)