|
1 |
| -from _typeshed import Incomplete |
2 |
| -from collections.abc import Sequence |
| 1 | +from collections.abc import Callable, MutableMapping, Sequence |
| 2 | +from typing import Any, Final, Literal, overload |
| 3 | +from typing_extensions import deprecated |
3 | 4 |
|
4 | 5 | import click
|
5 | 6 |
|
6 | 7 | __all__ = ["DefaultGroup"]
|
7 |
| -__version__: str |
| 8 | +__version__: Final[str] |
8 | 9 |
|
9 | 10 | class DefaultGroup(click.Group):
|
10 | 11 | ignore_unknown_options: bool
|
11 | 12 | default_cmd_name: str | None
|
12 | 13 | default_if_no_args: bool
|
13 |
| - def __init__(self, *args, **kwargs) -> None: ... |
| 14 | + # type hints were taken from click lib |
| 15 | + def __init__( |
| 16 | + self, |
| 17 | + name: str | None = None, |
| 18 | + commands: MutableMapping[str, click.Command] | Sequence[click.Command] | None = None, |
| 19 | + *, |
| 20 | + ignore_unknown_options: Literal[True] | None = True, |
| 21 | + default_cmd_name: str | None = None, |
| 22 | + default_if_no_args: bool = False, |
| 23 | + invoke_without_command: bool = False, |
| 24 | + no_args_is_help: bool | None = None, |
| 25 | + subcommand_metavar: str | None = None, |
| 26 | + chain: bool = False, |
| 27 | + result_callback: Callable[..., Any] | None = None, # Any is specified in click lib |
| 28 | + context_settings: MutableMapping[str, Any] | None = None, # Any is specified in click lib |
| 29 | + callback: Callable[..., Any] | None = None, # Any is specified in click lib |
| 30 | + params: list[click.Parameter] | None = None, |
| 31 | + help: str | None = None, |
| 32 | + epilog: str | None = None, |
| 33 | + short_help: str | None = None, |
| 34 | + options_metavar: str | None = "[OPTIONS]", |
| 35 | + add_help_option: bool = True, |
| 36 | + hidden: bool = False, |
| 37 | + deprecated: bool = False, |
| 38 | + ) -> None: ... |
14 | 39 | def set_default_command(self, command: click.Command) -> None: ...
|
15 | 40 | def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]: ...
|
16 | 41 | def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None: ...
|
17 | 42 | def resolve_command(self, ctx: click.Context, args: list[str]) -> tuple[str | None, click.Command | None, list[str]]: ...
|
18 | 43 | def format_commands(self, ctx: click.Context, formatter: click.HelpFormatter) -> None: ...
|
19 |
| - def command(self, *args, **kwargs) -> click.Command: ... # incomplete |
| 44 | + @overload |
| 45 | + def command( |
| 46 | + self, |
| 47 | + __func: Callable[..., Any], |
| 48 | + /, |
| 49 | + *, |
| 50 | + name: str | None = ..., |
| 51 | + cls: type[click.Command] | None = ..., |
| 52 | + default: Literal[False] = False, |
| 53 | + ) -> click.Command: ... |
| 54 | + @overload |
| 55 | + @deprecated("Use default param of `DefaultGroup` or `set_default_command()` instead") |
| 56 | + def command( |
| 57 | + self, |
| 58 | + __func: Callable[..., Any], |
| 59 | + /, |
| 60 | + *, |
| 61 | + name: str | None = ..., |
| 62 | + cls: type[click.Command] | None = ..., |
| 63 | + default: Literal[True], |
| 64 | + ) -> click.Command: ... |
| 65 | + @overload |
| 66 | + def command( |
| 67 | + self, *, name: str | None = ..., cls: type[click.Command] | None = ..., default: Literal[False] = False |
| 68 | + ) -> Callable[[Callable[..., Any]], click.Command]: ... |
| 69 | + @overload |
| 70 | + @deprecated("Use default param of `DefaultGroup` or `set_default_command()` instead") |
| 71 | + def command( |
| 72 | + self, *, name: str | None = ..., cls: type[click.Command] | None = ..., default: Literal[True] |
| 73 | + ) -> Callable[[Callable[..., Any]], click.Command]: ... |
| 74 | + @overload |
| 75 | + def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], click.Command] | click.Command: ... |
20 | 76 |
|
21 | 77 | class DefaultCommandFormatter:
|
22 | 78 | group: click.Group
|
23 | 79 | formatter: click.HelpFormatter
|
24 | 80 | mark: str
|
25 |
| - def __init__(self, group: click.Group, formatter: click.HelpFormatter, mark: str = ...) -> None: ... |
| 81 | + def __init__(self, group: click.Group, formatter: click.HelpFormatter, mark: str = "*") -> None: ... |
26 | 82 | def write_dl(self, rows: Sequence[tuple[str, str]], col_max: int = 30, col_spacing: int = -2) -> None: ...
|
27 |
| - def __getattr__(self, attr: str) -> Incomplete: ... |
28 |
| - # __getattr__ used to ala-derive from click.HelpFormatter: |
29 |
| - # indent_increment: int |
30 |
| - # width: int | None |
31 |
| - # current_indent: int |
32 |
| - # buffer: t.List[str] |
33 |
| - # def write(self, string: str) -> None: ... |
34 |
| - # def indent(self) -> None: ... |
35 |
| - # def dedent(self) -> None: ... |
36 |
| - # def write_usage(self, prog: str, args: str = ..., prefix: str | None = ...) -> None: ... |
37 |
| - # def write_heading(self, heading: str) -> None: ... |
38 |
| - # def write_paragraph(self) -> None: ... |
39 |
| - # def write_text(self, text: str) -> None: ... |
40 |
| - # def section(self, name: str) -> t.Iterator[None]: ... |
41 |
| - # def indentation(self) -> t.Iterator[None]: ... |
42 |
| - # def getvalue(self) -> str: ... |
| 83 | + def __getattr__(self, attr: str) -> Any: ... # attribute access is forwarded to click.HelpFormatter |
0 commit comments