[commands] Fix typing of check/check_any

This changes the type information of check decorators to return a
protocol representing that the decorator leaves the underlying object
unchanged while having a .predicate attribute.

resolves #7949
This commit is contained in:
Michael H
2022-05-02 18:54:49 -04:00
committed by GitHub
parent 4a73de946a
commit d0667d08e3
4 changed files with 36 additions and 26 deletions

View File

@ -60,7 +60,7 @@ if TYPE_CHECKING:
from .parameters import Parameter
from ._types import (
Check,
UserCheck,
ContextT,
BotT,
_Bot,
@ -378,7 +378,7 @@ class HelpCommand:
bot.remove_command(self._command_impl.name)
self._command_impl._eject_cog()
def add_check(self, func: Check[ContextT], /) -> None:
def add_check(self, func: UserCheck[ContextT], /) -> None:
"""
Adds a check to the help command.
@ -396,7 +396,7 @@ class HelpCommand:
self._command_impl.add_check(func)
def remove_check(self, func: Check[ContextT], /) -> None:
def remove_check(self, func: UserCheck[ContextT], /) -> None:
"""
Removes a check from the help command.