From 4695370071b543f6261fcaa26705323ae064050b Mon Sep 17 00:00:00 2001 From: Jonxslays <51417989+Jonxslays@users.noreply.github.com> Date: Fri, 22 Apr 2022 05:06:51 -0700 Subject: [PATCH] use verbose Callable for @command and @group --- CHANGES.rst | 3 +++ src/click/decorators.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f79a531c4..a618f5a8c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ------------- diff --git a/src/click/decorators.py b/src/click/decorators.py index ef1b1a51a..28618dc52 100644 --- a/src/click/decorators.py +++ b/src/click/decorators.py @@ -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]]: @@ -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 @@ -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: ... @@ -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`