mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 08:23:09 +00:00
Update types to use Awaitable where possible
This commit is contained in:
@@ -140,10 +140,7 @@ if TYPE_CHECKING:
|
||||
|
||||
P = ParamSpec('P')
|
||||
|
||||
MaybeCoroFunc = Union[
|
||||
Callable[P, Coroutine[Any, Any, 'T']],
|
||||
Callable[P, 'T'],
|
||||
]
|
||||
MaybeAwaitableFunc = Callable[P, 'MaybeAwaitable[T]']
|
||||
|
||||
_SnowflakeListBase = array.array[int]
|
||||
|
||||
@@ -156,6 +153,7 @@ T = TypeVar('T')
|
||||
T_co = TypeVar('T_co', covariant=True)
|
||||
_Iter = Union[Iterable[T], AsyncIterable[T]]
|
||||
Coro = Coroutine[Any, Any, T]
|
||||
MaybeAwaitable = Union[T, Awaitable[T]]
|
||||
|
||||
|
||||
class CachedSlotProperty(Generic[T, T_co]):
|
||||
@@ -615,7 +613,7 @@ def _parse_ratelimit_header(request: Any, *, use_clock: bool = False) -> float:
|
||||
return float(reset_after)
|
||||
|
||||
|
||||
async def maybe_coroutine(f: MaybeCoroFunc[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
|
||||
async def maybe_coroutine(f: MaybeAwaitableFunc[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
|
||||
value = f(*args, **kwargs)
|
||||
if _isawaitable(value):
|
||||
return await value
|
||||
|
Reference in New Issue
Block a user