mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-18 23:15:48 +00:00
[commands] Fix missing or inferred type hints in parameters.py
This commit is contained in:
parent
76cc2c2272
commit
b32b78de45
@ -26,7 +26,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from typing import TYPE_CHECKING, Any, Literal, Optional, OrderedDict, Union
|
from typing import TYPE_CHECKING, Any, Literal, Optional, OrderedDict, Union, Protocol
|
||||||
|
|
||||||
from discord.utils import MISSING, maybe_coroutine
|
from discord.utils import MISSING, maybe_coroutine
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class Parameter(inspect.Parameter):
|
|||||||
|
|
||||||
return None if self.required else str(self.default)
|
return None if self.required else str(self.default)
|
||||||
|
|
||||||
async def get_default(self, ctx: Context) -> Any:
|
async def get_default(self, ctx: Context[Any]) -> Any:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
Gets this parameter's default value.
|
Gets this parameter's default value.
|
||||||
@ -217,7 +217,18 @@ def parameter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
param = parameter
|
class ParameterAlias(Protocol):
|
||||||
|
def __call__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
converter: Any = empty,
|
||||||
|
default: Any = empty,
|
||||||
|
displayed_default: str = empty,
|
||||||
|
) -> Any:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
param: ParameterAlias = parameter
|
||||||
r"""param(\*, converter=..., default=..., displayed_default=...)
|
r"""param(\*, converter=..., default=..., displayed_default=...)
|
||||||
|
|
||||||
An alias for :func:`parameter`.
|
An alias for :func:`parameter`.
|
||||||
@ -241,7 +252,7 @@ CurrentChannel = parameter(
|
|||||||
CurrentChannel._fallback = True
|
CurrentChannel._fallback = True
|
||||||
|
|
||||||
|
|
||||||
def default_guild(ctx: Context) -> Guild:
|
def default_guild(ctx: Context[Any]) -> Guild:
|
||||||
if ctx.guild is not None:
|
if ctx.guild is not None:
|
||||||
return ctx.guild
|
return ctx.guild
|
||||||
raise NoPrivateMessage()
|
raise NoPrivateMessage()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user