mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-09 03:07:00 +00:00
Fix nested Annotated calls not resolving
This commit is contained in:
@ -750,9 +750,6 @@ def get_supported_annotation(
|
||||
if isinstance(annotation, Transformer):
|
||||
return (annotation, MISSING, False)
|
||||
|
||||
if hasattr(annotation, '__metadata__'):
|
||||
return get_supported_annotation(annotation.__metadata__[0])
|
||||
|
||||
if inspect.isclass(annotation):
|
||||
if issubclass(annotation, Transformer):
|
||||
return (annotation(), MISSING, False)
|
||||
|
@ -160,12 +160,6 @@ 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]
|
||||
|
||||
params[name] = parameter.replace(annotation=annotation)
|
||||
|
||||
return params
|
||||
|
@ -184,11 +184,6 @@ def get_flags(namespace: Dict[str, Any], globals: Dict[str, Any], locals: Dict[s
|
||||
flag.name = name
|
||||
|
||||
annotation = flag.annotation = resolve_annotation(flag.annotation, globals, locals, cache)
|
||||
if hasattr(annotation, '__metadata__'):
|
||||
# Annotated[X, Y] can access Y via __metadata__
|
||||
metadata = annotation.__metadata__
|
||||
if len(metadata) >= 1:
|
||||
annotation = flag.annotation = metadata[0]
|
||||
|
||||
if flag.default is MISSING and hasattr(annotation, '__commands_is_flag__') and annotation._can_be_constructible():
|
||||
flag.default = annotation._construct_default
|
||||
|
@ -1062,6 +1062,11 @@ def evaluate_annotation(
|
||||
cache[tp] = evaluated
|
||||
return evaluated
|
||||
|
||||
if hasattr(tp, '__metadata__'):
|
||||
# Annotated[X, Y] can access Y via __metadata__
|
||||
metadata = tp.__metadata__[0]
|
||||
return evaluate_annotation(metadata, globals, locals, cache)
|
||||
|
||||
if hasattr(tp, '__args__'):
|
||||
implicit_str = True
|
||||
is_literal = False
|
||||
|
Reference in New Issue
Block a user