mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 11:57:17 +00:00
Allow internal library enums to be used as an annotation
This commit is contained in:
parent
65418414ea
commit
3bb4d3bd6d
@ -47,7 +47,7 @@ from typing import (
|
|||||||
from .errors import AppCommandError, TransformerError
|
from .errors import AppCommandError, TransformerError
|
||||||
from .models import AppCommandChannel, AppCommandThread, Choice
|
from .models import AppCommandChannel, AppCommandThread, Choice
|
||||||
from ..channel import StageChannel, VoiceChannel, TextChannel, CategoryChannel
|
from ..channel import StageChannel, VoiceChannel, TextChannel, CategoryChannel
|
||||||
from ..enums import AppCommandOptionType, ChannelType
|
from ..enums import Enum as InternalEnum, AppCommandOptionType, ChannelType
|
||||||
from ..utils import MISSING, maybe_coroutine
|
from ..utils import MISSING, maybe_coroutine
|
||||||
from ..user import User
|
from ..user import User
|
||||||
from ..role import Role
|
from ..role import Role
|
||||||
@ -610,7 +610,7 @@ def get_supported_annotation(
|
|||||||
if inspect.isclass(annotation):
|
if inspect.isclass(annotation):
|
||||||
if issubclass(annotation, Transformer):
|
if issubclass(annotation, Transformer):
|
||||||
return (annotation, MISSING)
|
return (annotation, MISSING)
|
||||||
if issubclass(annotation, Enum):
|
if issubclass(annotation, (Enum, InternalEnum)):
|
||||||
return (_make_enum_transformer(annotation), MISSING)
|
return (_make_enum_transformer(annotation), MISSING)
|
||||||
if annotation is Choice:
|
if annotation is Choice:
|
||||||
raise TypeError(f'Choice requires a type argument of int, str, or float')
|
raise TypeError(f'Choice requires a type argument of int, str, or float')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user