mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 10:53:10 +00:00
[commands] Add support for typing.Annotated
This commit is contained in:
@ -625,6 +625,9 @@ def get_supported_annotation(
|
||||
if hasattr(annotation, '__discord_app_commands_transform__'):
|
||||
return (annotation.metadata, MISSING)
|
||||
|
||||
if hasattr(annotation, '__metadata__'):
|
||||
return get_supported_annotation(annotation.__metadata__[0])
|
||||
|
||||
if inspect.isclass(annotation):
|
||||
if issubclass(annotation, Transformer):
|
||||
return (annotation, MISSING)
|
||||
|
@ -161,6 +161,12 @@ def get_signature_parameters(
|
||||
if annotation is Greedy:
|
||||
raise TypeError('Unparameterized Greedy[...] is disallowed in signature.')
|
||||
|
||||
if hasattr(annotation, '__metadata__'):
|
||||
# Annotated[X, Y] can access Y via __metadata__
|
||||
metadata = annotation.__metadata__
|
||||
if len(metadata) >= 1:
|
||||
annotation = metadata[0]
|
||||
|
||||
if isinstance(annotation, discord.app_commands.transformers._TransformMetadata):
|
||||
annotation = annotation.metadata
|
||||
|
||||
|
Reference in New Issue
Block a user