Skip to content

Commit

Permalink
refactor: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Denis Laxalde <denis@laxalde.org>
  • Loading branch information
henryiii and dlax committed Mar 30, 2022
1 parent 41ae48b commit a8fe905
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/click/core.py
Expand Up @@ -1843,7 +1843,9 @@ def command(

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

if len(args) == 1 and not kwargs and callable(args[0]):
if 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 = ()

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/click/decorators.py
Expand Up @@ -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:
...

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

@t.overload
def group(
__name: t.Callable,
__func: t.Callable,
) -> Group:
...

Expand Down

0 comments on commit a8fe905

Please sign in to comment.