Skip to content

Commit

Permalink
enclose in square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
peco2282 authored and Lulalaby committed Jun 29, 2022
1 parent 13c567f commit ecadcc4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 33 deletions.
8 changes: 4 additions & 4 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,17 @@ async def __call__(self, ctx, *args, **kwargs):
def callback(
self,
) -> Union[
Callable[Concatenate[CogT, ApplicationContext, P], Coro[T]],
Callable[Concatenate[ApplicationContext, P], Coro[T]],
Callable[[Concatenate[CogT, ApplicationContext, P]], Coro[T]],
Callable[[Concatenate[ApplicationContext, P]], Coro[T]],
]:
return self._callback

@callback.setter
def callback(
self,
function: Union[
Callable[Concatenate[CogT, ApplicationContext, P], Coro[T]],
Callable[Concatenate[ApplicationContext, P], Coro[T]],
Callable[[Concatenate[CogT, ApplicationContext, P]], Coro[T]],
Callable[[Concatenate[ApplicationContext, P]], Coro[T]],
],
) -> None:
self._callback = function
Expand Down
100 changes: 71 additions & 29 deletions discord/ext/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,14 @@ def __new__(cls: Type[CommandT], *args: Any, **kwargs: Any) -> CommandT:
def __init__(
self,
func: Union[
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[Concatenate[ContextT, P], Coro[T]],
Callable[
[Concatenate[CogT, ContextT, P]],
Coro[T]
],
Callable[
[Concatenate[ContextT, P]],
Coro[T]
],
],
**kwargs: Any,
):
Expand Down Expand Up @@ -414,15 +420,30 @@ def __init__(
@property
def callback(
self,
) -> Union[Callable[Concatenate[CogT, Context, P], Coro[T]], Callable[Concatenate[Context, P], Coro[T]],]:
) -> Union[
Callable[
[Concatenate[CogT, Context, P]],
Coro[T]
],
Callable[
[Concatenate[Context, P]],
Coro[T]
],
]:
return self._callback

@callback.setter
def callback(
self,
function: Union[
Callable[Concatenate[CogT, Context, P], Coro[T]],
Callable[Concatenate[Context, P], Coro[T]],
Callable[
[Concatenate[CogT, Context, P]],
Coro[T]
],
Callable[
[Concatenate[Context, P]],
Coro[T]
],
],
) -> None:
self._callback = function
Expand Down Expand Up @@ -1343,8 +1364,14 @@ def command(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[Concatenate[ContextT, P], Coro[T]],
Callable[
[Concatenate[CogT, ContextT, P]],
Coro[T]
],
Callable[
[Concatenate[ContextT, P]],
Coro[T]
],
]
],
Command[CogT, P, T],
Expand All @@ -1358,7 +1385,14 @@ def command(
cls: Type[CommandT] = ...,
*args: Any,
**kwargs: Any,
) -> Callable[[Callable[Concatenate[ContextT, P], Coro[Any]]], CommandT]:
) -> Callable[
[Callable[
[Concatenate[ContextT, P]],
Coro[Any]
]
],
CommandT
]:
...

def command(
Expand All @@ -1367,7 +1401,15 @@ def command(
cls: Type[CommandT] = MISSING,
*args: Any,
**kwargs: Any,
) -> Callable[[Callable[Concatenate[ContextT, P], Coro[Any]]], CommandT]:
) -> Callable[
[
Callable[
[Concatenate[ContextT, P]],
Coro[Any]
]
],
CommandT
]:
"""A shortcut decorator that invokes :func:`.command` and adds it to
the internal command list via :meth:`~.GroupMixin.add_command`.
Expand All @@ -1377,7 +1419,7 @@ def command(
A decorator that converts the provided method into a Command, adds it to the bot, then returns it.
"""

def decorator(func: Callable[Concatenate[ContextT, P], Coro[Any]]) -> CommandT:
def decorator(func: Callable[[Concatenate[ContextT, P]], Coro[Any]]) -> CommandT:
kwargs.setdefault("parent", self)
result = command(name=name, cls=cls, *args, **kwargs)(func)
self.add_command(result)
Expand All @@ -1395,8 +1437,8 @@ def group(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[Concatenate[ContextT, P], Coro[T]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[T]],
Callable[[Concatenate[ContextT, P]], Coro[T]],
]
],
Group[CogT, P, T],
Expand All @@ -1410,7 +1452,7 @@ def group(
cls: Type[GroupT] = ...,
*args: Any,
**kwargs: Any,
) -> Callable[[Callable[Concatenate[ContextT, P], Coro[Any]]], GroupT]:
) -> Callable[[Callable[[Concatenate[ContextT, P]], Coro[Any]]], GroupT]:
...

def group(
Expand All @@ -1419,7 +1461,7 @@ def group(
cls: Type[GroupT] = MISSING,
*args: Any,
**kwargs: Any,
) -> Callable[[Callable[Concatenate[ContextT, P], Coro[Any]]], GroupT]:
) -> Callable[[Callable[[Concatenate[ContextT, P]], Coro[Any]]], GroupT]:
"""A shortcut decorator that invokes :func:`.group` and adds it to
the internal command list via :meth:`~.GroupMixin.add_command`.
Expand All @@ -1429,7 +1471,7 @@ def group(
A decorator that converts the provided method into a Group, adds it to the bot, then returns it.
"""

def decorator(func: Callable[Concatenate[ContextT, P], Coro[Any]]) -> GroupT:
def decorator(func: Callable[[Concatenate[ContextT, P]], Coro[Any]]) -> GroupT:
kwargs.setdefault("parent", self)
result = group(name=name, cls=cls, *args, **kwargs)(func)
self.add_command(result)
Expand Down Expand Up @@ -1561,8 +1603,8 @@ def command(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[Concatenate[ContextT, P], Coro[T]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[T]],
Callable[[Concatenate[ContextT, P]], Coro[T]],
]
],
Command[CogT, P, T],
Expand All @@ -1578,8 +1620,8 @@ def command(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[Any]],
Callable[Concatenate[ContextT, P], Coro[Any]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[Any]],
Callable[[Concatenate[ContextT, P]], Coro[Any]],
]
],
CommandT,
Expand All @@ -1592,8 +1634,8 @@ def command(
) -> Callable[
[
Union[
Callable[Concatenate[ContextT, P], Coro[Any]],
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[[Concatenate[ContextT, P]], Coro[Any]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[T]],
]
],
Union[Command[CogT, P, T], CommandT],
Expand Down Expand Up @@ -1632,8 +1674,8 @@ def command(

def decorator(
func: Union[
Callable[Concatenate[ContextT, P], Coro[Any]],
Callable[Concatenate[CogT, ContextT, P], Coro[Any]],
Callable[[Concatenate[ContextT, P]], Coro[Any]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[Any]],
]
) -> CommandT:
if isinstance(func, Command):
Expand All @@ -1651,8 +1693,8 @@ def group(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[Concatenate[ContextT, P], Coro[T]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[T]],
Callable[[Concatenate[ContextT, P]], Coro[T]],
]
],
Group[CogT, P, T],
Expand All @@ -1668,8 +1710,8 @@ def group(
) -> Callable[
[
Union[
Callable[Concatenate[CogT, ContextT, P], Coro[Any]],
Callable[Concatenate[ContextT, P], Coro[Any]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[Any]],
Callable[[Concatenate[ContextT, P]], Coro[Any]],
]
],
GroupT,
Expand All @@ -1684,8 +1726,8 @@ def group(
) -> Callable[
[
Union[
Callable[Concatenate[ContextT, P], Coro[Any]],
Callable[Concatenate[CogT, ContextT, P], Coro[T]],
Callable[[Concatenate[ContextT, P]], Coro[Any]],
Callable[[Concatenate[CogT, ContextT, P]], Coro[T]],
]
],
Union[Group[CogT, P, T], GroupT],
Expand Down

0 comments on commit ecadcc4

Please sign in to comment.