diff --git a/src/click/core.py b/src/click/core.py index 27f78ea79..f7f4cbafc 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -1843,7 +1843,9 @@ def command( func: t.Optional[t.Callable] = None - if len(args) == 1 and not kwargs and callable(args[0]): + if args and callable(args[0]): + assert len(args) == 1, "Please use command(name, ...)(callable) instead" + assert not kwargs, "Please use command(name, ...)(callable) instead" (func,) = args args = () @@ -1891,7 +1893,7 @@ def group( if args and callable(args[0]): assert len(args) == 1, "Please use group(...)(callable) instead" assert not kwargs, "Please use group(...)(callable) instead" - func = args[0] + (func,) = args args = () if self.group_class is not None and kwargs.get("cls") is None: diff --git a/src/click/decorators.py b/src/click/decorators.py index d55d22312..690b3f3a8 100644 --- a/src/click/decorators.py +++ b/src/click/decorators.py @@ -126,7 +126,7 @@ def new_func(*args, **kwargs): # type: ignore @t.overload def command( - __name: t.Callable[..., t.Any], + __func: t.Callable[..., t.Any], ) -> Command: ... @@ -228,7 +228,7 @@ def decorator(f: t.Callable[..., t.Any]) -> Command: @t.overload def group( - __name: t.Callable, + __func: t.Callable, ) -> Group: ...