[commands] Require number of parameters at instantiation time

This allows it to bypass annotation evaluation for arguments that don't
matter like self and context.
This commit is contained in:
Rapptz
2022-02-25 10:53:21 -05:00
parent 0b5c3cf256
commit 8226f0df2c
2 changed files with 25 additions and 30 deletions

View File

@@ -1061,6 +1061,21 @@ def resolve_annotation(
return evaluate_annotation(annotation, globalns, locals, cache)
def is_inside_class(func: Callable[..., Any]) -> bool:
# For methods defined in a class, the qualname has a dotted path
# denoting which class it belongs to. So, e.g. for A.foo the qualname
# would be A.foo while a global foo() would just be foo.
#
# Unfortuately, for nested functions this breaks. So inside an outer
# function named outer, those two would end up having a qualname with
# outer.<locals>.A.foo and outer.<locals>.foo
if func.__qualname__ == func.__name__:
return False
(remaining, _, _) = func.__qualname__.rpartition('.')
return not remaining.endswith('<locals>')
TimestampStyle = Literal['f', 'F', 'd', 'D', 't', 'T', 'R']