Browse Source

Allow internal library enums to be used as an annotation

pull/7881/head
Rapptz 3 years ago
parent
commit
3bb4d3bd6d
  1. 4
      discord/app_commands/transformers.py

4
discord/app_commands/transformers.py

@ -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…
Cancel
Save