mirror of
https://github.com/Rapptz/discord.py.git
synced 2026-09-21 03:27:42 +00:00
Use iscoroutinefunction from inspect instead of asyncio on 3.12+
This commit is contained in:
@@ -26,7 +26,6 @@ from __future__ import annotations
|
||||
|
||||
import copy
|
||||
from typing import Callable, Literal, Optional, TYPE_CHECKING, Tuple, TypeVar, Union
|
||||
import inspect
|
||||
import os
|
||||
|
||||
|
||||
@@ -34,6 +33,7 @@ from .item import Item, ContainedItemCallbackType as ItemCallbackType, _ItemCall
|
||||
from ..enums import ButtonStyle, ComponentType
|
||||
from ..partial_emoji import PartialEmoji, _EmojiTag
|
||||
from ..components import Button as ButtonComponent
|
||||
from ..utils import _iscoroutinefunction
|
||||
|
||||
__all__ = (
|
||||
'Button',
|
||||
@@ -370,7 +370,7 @@ def button(
|
||||
"""
|
||||
|
||||
def decorator(func: ItemCallbackType[S, Button[V]]) -> ItemCallbackType[S, Button[V]]:
|
||||
if not inspect.iscoroutinefunction(func):
|
||||
if not _iscoroutinefunction(func):
|
||||
raise TypeError('button function must be a coroutine function')
|
||||
|
||||
func.__discord_ui_model_type__ = Button
|
||||
|
||||
@@ -40,14 +40,13 @@ from typing import (
|
||||
)
|
||||
from contextvars import ContextVar
|
||||
import copy
|
||||
import inspect
|
||||
import os
|
||||
|
||||
from .item import Item, ContainedItemCallbackType as ItemCallbackType, _ItemCallback
|
||||
from ..enums import ChannelType, ComponentType, SelectDefaultValueType
|
||||
from ..partial_emoji import PartialEmoji
|
||||
from ..emoji import Emoji
|
||||
from ..utils import MISSING, _human_join
|
||||
from ..utils import MISSING, _human_join, _iscoroutinefunction
|
||||
from ..components import (
|
||||
SelectOption,
|
||||
SelectMenu,
|
||||
@@ -1209,7 +1208,7 @@ def select(
|
||||
"""
|
||||
|
||||
def decorator(func: ItemCallbackType[S, BaseSelectT]) -> ItemCallbackType[S, BaseSelectT]:
|
||||
if not inspect.iscoroutinefunction(func):
|
||||
if not _iscoroutinefunction(func):
|
||||
raise TypeError('select function must be a coroutine function')
|
||||
callback_cls = getattr(cls, '__origin__', cls)
|
||||
if not issubclass(callback_cls, BaseSelect):
|
||||
|
||||
Reference in New Issue
Block a user