Merge branch 'iDevision:2.0' into ProtocolUrls
This commit is contained in:
commit
461abea6c2
@ -1032,6 +1032,8 @@ class Option(Generic[T, DT]): # type: ignore
|
|||||||
The default for this option, overwrites Option during parsing.
|
The default for this option, overwrites Option during parsing.
|
||||||
description: :class:`str`
|
description: :class:`str`
|
||||||
The description for this option, is unpacked to :attr:`.Command.option_descriptions`
|
The description for this option, is unpacked to :attr:`.Command.option_descriptions`
|
||||||
|
name: :class:`str`
|
||||||
|
The name of the option. This defaults to the parameter name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
description: DT
|
description: DT
|
||||||
@ -1039,16 +1041,20 @@ class Option(Generic[T, DT]): # type: ignore
|
|||||||
__slots__ = (
|
__slots__ = (
|
||||||
"default",
|
"default",
|
||||||
"description",
|
"description",
|
||||||
|
"name",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, default: T = inspect.Parameter.empty, *, description: DT) -> None:
|
def __init__(
|
||||||
|
self, default: T = inspect.Parameter.empty, *, description: DT, name: str = discord.utils.MISSING
|
||||||
|
) -> None:
|
||||||
self.description = description
|
self.description = description
|
||||||
self.default = default
|
self.default = default
|
||||||
|
self.name: str = name
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
# Terrible workaround for type checking reasons
|
# Terrible workaround for type checking reasons
|
||||||
def Option(default: T = inspect.Parameter.empty, *, description: str) -> T:
|
def Option(default: T = inspect.Parameter.empty, *, description: str, name: str = discord.utils.MISSING) -> T:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,8 +174,12 @@ def get_signature_parameters(
|
|||||||
annotation = parameter.annotation
|
annotation = parameter.annotation
|
||||||
if isinstance(parameter.default, Option): # type: ignore
|
if isinstance(parameter.default, Option): # type: ignore
|
||||||
option = parameter.default
|
option = parameter.default
|
||||||
descriptions[name] = option.description
|
|
||||||
parameter = parameter.replace(default=option.default)
|
parameter = parameter.replace(default=option.default)
|
||||||
|
if option.name is not MISSING:
|
||||||
|
name = option.name
|
||||||
|
parameter.replace(name=name)
|
||||||
|
|
||||||
|
descriptions[name] = option.description
|
||||||
|
|
||||||
if annotation is parameter.empty:
|
if annotation is parameter.empty:
|
||||||
params[name] = parameter
|
params[name] = parameter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user