Skip to content

Expand args and kwargs for click_default_group methods #13873

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

Merged
merged 2 commits into from
Apr 24, 2025
Merged
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
1 change: 0 additions & 1 deletion pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@
"stubs/braintree",
"stubs/caldav",
"stubs/cffi",
"stubs/click-default-group",
"stubs/click-web",
"stubs/corus",
"stubs/dateparser",
2 changes: 1 addition & 1 deletion stubs/click-default-group/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.2.*"
upstream_repository = "https://github.com/click-contrib/click-default-group"
# requires a version of click with a py.typed
requires = ["click>=8.0.0"]
upstream_repository = "https://github.com/click-contrib/click-default-group"
85 changes: 63 additions & 22 deletions stubs/click-default-group/click_default_group.pyi
Original file line number Diff line number Diff line change
@@ -1,42 +1,83 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from collections.abc import Callable, MutableMapping, Sequence
from typing import Any, Final, Literal, overload
from typing_extensions import deprecated

import click

__all__ = ["DefaultGroup"]
__version__: str
__version__: Final[str]

class DefaultGroup(click.Group):
ignore_unknown_options: bool
default_cmd_name: str | None
default_if_no_args: bool
def __init__(self, *args, **kwargs) -> None: ...
# type hints were taken from click lib
def __init__(
self,
name: str | None = None,
commands: MutableMapping[str, click.Command] | Sequence[click.Command] | None = None,
*,
ignore_unknown_options: Literal[True] | None = True,
default_cmd_name: str | None = None,
default_if_no_args: bool = False,
invoke_without_command: bool = False,
no_args_is_help: bool | None = None,
subcommand_metavar: str | None = None,
chain: bool = False,
result_callback: Callable[..., Any] | None = None, # Any is specified in click lib
context_settings: MutableMapping[str, Any] | None = None, # Any is specified in click lib
callback: Callable[..., Any] | None = None, # Any is specified in click lib
params: list[click.Parameter] | None = None,
help: str | None = None,
epilog: str | None = None,
short_help: str | None = None,
options_metavar: str | None = "[OPTIONS]",
add_help_option: bool = True,
hidden: bool = False,
deprecated: bool = False,
) -> None: ...
def set_default_command(self, command: click.Command) -> None: ...
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]: ...
def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None: ...
def resolve_command(self, ctx: click.Context, args: list[str]) -> tuple[str | None, click.Command | None, list[str]]: ...
def format_commands(self, ctx: click.Context, formatter: click.HelpFormatter) -> None: ...
def command(self, *args, **kwargs) -> click.Command: ... # incomplete
@overload
def command(
self,
__func: Callable[..., Any],
/,
*,
name: str | None = ...,
cls: type[click.Command] | None = ...,
default: Literal[False] = False,
) -> click.Command: ...
@overload
@deprecated("Use default param of `DefaultGroup` or `set_default_command()` instead")
def command(
self,
__func: Callable[..., Any],
/,
*,
name: str | None = ...,
cls: type[click.Command] | None = ...,
default: Literal[True],
) -> click.Command: ...
@overload
def command(
self, *, name: str | None = ..., cls: type[click.Command] | None = ..., default: Literal[False] = False
) -> Callable[[Callable[..., Any]], click.Command]: ...
@overload
@deprecated("Use default param of `DefaultGroup` or `set_default_command()` instead")
def command(
self, *, name: str | None = ..., cls: type[click.Command] | None = ..., default: Literal[True]
) -> Callable[[Callable[..., Any]], click.Command]: ...
@overload
def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], click.Command] | click.Command: ...

class DefaultCommandFormatter:
group: click.Group
formatter: click.HelpFormatter
mark: str
def __init__(self, group: click.Group, formatter: click.HelpFormatter, mark: str = ...) -> None: ...
def __init__(self, group: click.Group, formatter: click.HelpFormatter, mark: str = "*") -> None: ...
def write_dl(self, rows: Sequence[tuple[str, str]], col_max: int = 30, col_spacing: int = -2) -> None: ...
def __getattr__(self, attr: str) -> Incomplete: ...
# __getattr__ used to ala-derive from click.HelpFormatter:
# indent_increment: int
# width: int | None
# current_indent: int
# buffer: t.List[str]
# def write(self, string: str) -> None: ...
# def indent(self) -> None: ...
# def dedent(self) -> None: ...
# def write_usage(self, prog: str, args: str = ..., prefix: str | None = ...) -> None: ...
# def write_heading(self, heading: str) -> None: ...
# def write_paragraph(self) -> None: ...
# def write_text(self, text: str) -> None: ...
# def section(self, name: str) -> t.Iterator[None]: ...
# def indentation(self) -> t.Iterator[None]: ...
# def getvalue(self) -> str: ...
def __getattr__(self, attr: str) -> Any: ... # attribute access is forwarded to click.HelpFormatter