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

Fix typing on command and group decorators #2256

Merged
merged 1 commit into from Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -5,6 +5,9 @@ Version 8.1.3

Unreleased

- Use verbose form of ``typing.Callable`` for ``@command`` and
``@group``. :issue:`2255`


Version 8.1.2
-------------
Expand Down
8 changes: 4 additions & 4 deletions src/click/decorators.py
Expand Up @@ -149,7 +149,7 @@ def command(


def command(
name: t.Union[str, t.Callable, None] = None,
name: t.Union[str, t.Callable[..., t.Any], None] = None,
cls: t.Optional[t.Type[Command]] = None,
**attrs: t.Any,
) -> t.Union[Command, t.Callable[..., Command]]:
Expand Down Expand Up @@ -182,7 +182,7 @@ def command(
appended to the end of the list.
"""

func: t.Optional[t.Callable] = None
func: t.Optional[t.Callable[..., t.Any]] = None

if callable(name):
func = name
Expand Down Expand Up @@ -228,7 +228,7 @@ def decorator(f: t.Callable[..., t.Any]) -> Command:

@t.overload
def group(
__func: t.Callable,
__func: t.Callable[..., t.Any],
) -> Group:
...

Expand All @@ -242,7 +242,7 @@ def group(


def group(
name: t.Union[str, t.Callable, None] = None, **attrs: t.Any
name: t.Union[str, t.Callable[..., t.Any], None] = None, **attrs: t.Any
) -> t.Union[Group, t.Callable[[F], Group]]:
"""Creates a new :class:`Group` with a function as callback. This
works otherwise the same as :func:`command` just that the `cls`
Expand Down