From bc07a02f68acae3aa1505e9733c6a51e7ab058d7 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 14 Apr 2022 05:14:48 -0400 Subject: [PATCH] [commands] Fix type hints for hybrid command decorators --- discord/ext/commands/hybrid.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/discord/ext/commands/hybrid.py b/discord/ext/commands/hybrid.py index 2c9587614..bb1cf0fac 100644 --- a/discord/ext/commands/hybrid.py +++ b/discord/ext/commands/hybrid.py @@ -68,6 +68,7 @@ __all__ = ( ) T = TypeVar('T') +U = TypeVar('U') CogT = TypeVar('CogT', bound='Cog') CommandT = TypeVar('CommandT', bound='Command') # CHT = TypeVar('CHT', bound='Check') @@ -592,7 +593,7 @@ class HybridGroup(Group[CogT, P, T]): name: str = MISSING, *args: Any, **kwargs: Any, - ) -> Callable[[CommandCallback[CogT, ContextT, P2, T]], HybridCommand[CogT, P2, T]]: + ) -> Callable[[CommandCallback[CogT, ContextT, P2, U]], HybridCommand[CogT, P2, U]]: """A shortcut decorator that invokes :func:`~discord.ext.commands.hybrid_command` and adds it to the internal command list via :meth:`add_command`. @@ -602,7 +603,7 @@ class HybridGroup(Group[CogT, P, T]): A decorator that converts the provided method into a Command, adds it to the bot, then returns it. """ - def decorator(func: CommandCallback[CogT, ContextT, P2, T]): + def decorator(func: CommandCallback[CogT, ContextT, P2, U]): kwargs.setdefault('parent', self) result = hybrid_command(name=name, *args, **kwargs)(func) self.add_command(result) @@ -615,7 +616,7 @@ class HybridGroup(Group[CogT, P, T]): name: str = MISSING, *args: Any, **kwargs: Any, - ) -> Callable[[CommandCallback[CogT, ContextT, P2, T]], HybridGroup[CogT, P2, T]]: + ) -> Callable[[CommandCallback[CogT, ContextT, P2, U]], HybridGroup[CogT, P2, U]]: """A shortcut decorator that invokes :func:`~discord.ext.commands.hybrid_group` and adds it to the internal command list via :meth:`~.GroupMixin.add_command`. @@ -625,7 +626,7 @@ class HybridGroup(Group[CogT, P, T]): A decorator that converts the provided method into a Group, adds it to the bot, then returns it. """ - def decorator(func: CommandCallback[CogT, ContextT, P2, T]): + def decorator(func: CommandCallback[CogT, ContextT, P2, U]): kwargs.setdefault('parent', self) result = hybrid_group(name=name, *args, **kwargs)(func) self.add_command(result)