From 92bf230c023649dc102b6852cddc860c377b6e77 Mon Sep 17 00:00:00 2001 From: Known_Black_Hat Date: Sun, 7 May 2023 16:56:39 -0400 Subject: [PATCH 1/5] fix: type error --- disnake/ext/commands/_types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/disnake/ext/commands/_types.py b/disnake/ext/commands/_types.py index eb90ee0a42..225b90f2c4 100644 --- a/disnake/ext/commands/_types.py +++ b/disnake/ext/commands/_types.py @@ -14,7 +14,9 @@ CoroFunc = Callable[..., Coro[Any]] Check = Union[ - Callable[["Cog", "Context[Any]"], MaybeCoro[bool]], Callable[["Context[Any]"], MaybeCoro[bool]] + Callable[["Cog"], Cog], + Callable[["Cog", "Context[Any]"], MaybeCoro[bool]], + Callable[["Context[Any]"], MaybeCoro[bool]], ] Hook = Union[Callable[["Cog", "Context[Any]"], Coro[Any]], Callable[["Context[Any]"], Coro[Any]]] Error = Union[ From 76474b8b3811577a5d8df4466b35e5ecb1ef56f7 Mon Sep 17 00:00:00 2001 From: Known_Black_Hat Date: Mon, 8 May 2023 04:32:52 +0000 Subject: [PATCH 2/5] fix: import error --- disnake/ext/commands/_types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/disnake/ext/commands/_types.py b/disnake/ext/commands/_types.py index 225b90f2c4..1a90b75722 100644 --- a/disnake/ext/commands/_types.py +++ b/disnake/ext/commands/_types.py @@ -2,8 +2,9 @@ from typing import TYPE_CHECKING, Any, Callable, Coroutine, TypeVar, Union +from .cog import Cog + if TYPE_CHECKING: - from .cog import Cog from .context import Context from .errors import CommandError From d7672784db2126c9ff62e1c8bd7482f44b37d459 Mon Sep 17 00:00:00 2001 From: Known_Black_Hat Date: Mon, 8 May 2023 08:40:40 +0000 Subject: [PATCH 3/5] test: types --- disnake/ext/commands/_types.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/disnake/ext/commands/_types.py b/disnake/ext/commands/_types.py index 1a90b75722..13053e7cfb 100644 --- a/disnake/ext/commands/_types.py +++ b/disnake/ext/commands/_types.py @@ -2,21 +2,20 @@ from typing import TYPE_CHECKING, Any, Callable, Coroutine, TypeVar, Union -from .cog import Cog - if TYPE_CHECKING: + from .cog import Cog from .context import Context from .errors import CommandError T = TypeVar("T") +test = TypeVar("test", bound=Cog) Coro = Coroutine[Any, Any, T] MaybeCoro = Union[T, Coro[T]] CoroFunc = Callable[..., Coro[Any]] Check = Union[ - Callable[["Cog"], Cog], - Callable[["Cog", "Context[Any]"], MaybeCoro[bool]], + Callable[["Cog"], test], Callable[["Context[Any]"], MaybeCoro[bool]], ] Hook = Union[Callable[["Cog", "Context[Any]"], Coro[Any]], Callable[["Context[Any]"], Coro[Any]]] From 8a7b69e5e1618a3fef4762389793a337eec6878a Mon Sep 17 00:00:00 2001 From: Known_Black_Hat Date: Mon, 8 May 2023 08:48:59 +0000 Subject: [PATCH 4/5] fix: type hinting --- disnake/ext/commands/_types.py | 4 ++-- disnake/ext/commands/core.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/disnake/ext/commands/_types.py b/disnake/ext/commands/_types.py index 13053e7cfb..6bc893b426 100644 --- a/disnake/ext/commands/_types.py +++ b/disnake/ext/commands/_types.py @@ -8,14 +8,14 @@ from .errors import CommandError T = TypeVar("T") -test = TypeVar("test", bound=Cog) Coro = Coroutine[Any, Any, T] MaybeCoro = Union[T, Coro[T]] CoroFunc = Callable[..., Coro[Any]] Check = Union[ - Callable[["Cog"], test], + Callable[["Cog"], Any], + Callable[["Cog", "Context[Any]"], MaybeCoro[bool]], Callable[["Context[Any]"], MaybeCoro[bool]], ] Hook = Union[Callable[["Cog", "Context[Any]"], Coro[Any]], Callable[["Context[Any]"], Coro[Any]]] diff --git a/disnake/ext/commands/core.py b/disnake/ext/commands/core.py index 53d88a418e..5f9287db2c 100644 --- a/disnake/ext/commands/core.py +++ b/disnake/ext/commands/core.py @@ -1774,7 +1774,7 @@ def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]: decorator.predicate = predicate else: - @functools.wraps(predicate) + @functools.wraps(predicate) # type: ignore async def wrapper(ctx): return predicate(ctx) # type: ignore From 1069b79251b7bc0a5f4707740796b562c4856b07 Mon Sep 17 00:00:00 2001 From: Known_Black_Hat Date: Mon, 8 May 2023 09:26:58 +0000 Subject: [PATCH 5/5] refactor: remove type ignore --- disnake/ext/commands/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/ext/commands/core.py b/disnake/ext/commands/core.py index 5f9287db2c..53d88a418e 100644 --- a/disnake/ext/commands/core.py +++ b/disnake/ext/commands/core.py @@ -1774,7 +1774,7 @@ def decorator(func: Union[Command, CoroFunc]) -> Union[Command, CoroFunc]: decorator.predicate = predicate else: - @functools.wraps(predicate) # type: ignore + @functools.wraps(predicate) async def wrapper(ctx): return predicate(ctx) # type: ignore