Skip to content

Commit

Permalink
fix: same fix applied to group
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Mar 30, 2022
1 parent 016df26 commit 41ae48b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,16 @@ def decorator(f: t.Callable[..., t.Any]) -> Command:

return decorator

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

@t.overload
def group(
self, *args: t.Any, **kwargs: t.Any
) -> t.Callable[[t.Callable[..., t.Any]], "Group"]:
...

def group(
self, *args: t.Any, **kwargs: t.Any
) -> t.Union[t.Callable[[t.Callable[..., t.Any]], "Group"], "Group"]:
Expand All @@ -1879,8 +1889,10 @@ def group(
func: t.Optional[t.Callable] = None

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]
args = args[1:]
args = ()

if self.group_class is not None and kwargs.get("cls") is None:
if self.group_class is type:
Expand Down
9 changes: 4 additions & 5 deletions src/click/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,16 @@ def decorator(f: t.Callable[..., t.Any]) -> Command:

@t.overload
def group(
name: t.Optional[str] = None,
**attrs: t.Any,
) -> t.Callable[[F], Group]:
__name: t.Callable,
) -> Group:
...


@t.overload
def group(
name: t.Callable,
name: t.Optional[str] = None,
**attrs: t.Any,
) -> Group:
) -> t.Callable[[F], Group]:
...


Expand Down

0 comments on commit 41ae48b

Please sign in to comment.