Alter return-type of button/select decorators

This commit is contained in:
Josh
2022-02-22 12:54:44 +10:00
committed by GitHub
parent 22b06e7bf8
commit d409ddd227
4 changed files with 9 additions and 10 deletions

View File

@ -234,7 +234,7 @@ def button(
style: ButtonStyle = ButtonStyle.secondary,
emoji: Optional[Union[str, Emoji, PartialEmoji]] = None,
row: Optional[int] = None,
) -> Callable[[ItemCallbackType], ItemCallbackType]:
) -> Callable[[ItemCallbackType[V, Button[V]]], Button[V]]:
"""A decorator that attaches a button to a component.
The function being decorated should have three parameters, ``self`` representing
@ -271,7 +271,7 @@ def button(
ordering. The row number must be between 0 and 4 (i.e. zero indexed).
"""
def decorator(func: ItemCallbackType) -> ItemCallbackType:
def decorator(func: ItemCallbackType[V, Button[V]]) -> ItemCallbackType[V, Button[V]]:
if not inspect.iscoroutinefunction(func):
raise TypeError('button function must be a coroutine function')
@ -287,4 +287,4 @@ def button(
}
return func
return decorator
return decorator # type: ignore