mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-21 16:03:10 +00:00
Fix typing issues and improve typing completeness across the library
Co-authored-by: Danny <Rapptz@users.noreply.github.com> Co-authored-by: Josh <josh.ja.butt@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ from typing import (
|
||||
Tuple,
|
||||
ClassVar,
|
||||
Optional,
|
||||
Type,
|
||||
overload,
|
||||
)
|
||||
|
||||
@@ -71,7 +72,6 @@ if TYPE_CHECKING:
|
||||
MessageReference as MessageReferencePayload,
|
||||
MessageApplication as MessageApplicationPayload,
|
||||
MessageActivity as MessageActivityPayload,
|
||||
Reaction as ReactionPayload,
|
||||
)
|
||||
|
||||
from .types.components import Component as ComponentPayload
|
||||
@@ -87,7 +87,7 @@ if TYPE_CHECKING:
|
||||
from .abc import GuildChannel, PartialMessageableChannel, MessageableChannel
|
||||
from .components import Component
|
||||
from .state import ConnectionState
|
||||
from .channel import TextChannel, GroupChannel, DMChannel
|
||||
from .channel import TextChannel
|
||||
from .mentions import AllowedMentions
|
||||
from .user import User
|
||||
from .role import Role
|
||||
@@ -95,6 +95,7 @@ if TYPE_CHECKING:
|
||||
|
||||
EmojiInputType = Union[Emoji, PartialEmoji, str]
|
||||
|
||||
|
||||
__all__ = (
|
||||
'Attachment',
|
||||
'Message',
|
||||
@@ -104,7 +105,7 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
def convert_emoji_reaction(emoji):
|
||||
def convert_emoji_reaction(emoji: Union[EmojiInputType, Reaction]) -> str:
|
||||
if isinstance(emoji, Reaction):
|
||||
emoji = emoji.emoji
|
||||
|
||||
@@ -216,7 +217,7 @@ class Attachment(Hashable):
|
||||
|
||||
async def save(
|
||||
self,
|
||||
fp: Union[io.BufferedIOBase, PathLike],
|
||||
fp: Union[io.BufferedIOBase, PathLike[Any]],
|
||||
*,
|
||||
seek_begin: bool = True,
|
||||
use_cached: bool = False,
|
||||
@@ -510,7 +511,7 @@ class MessageReference:
|
||||
to_message_reference_dict = to_dict
|
||||
|
||||
|
||||
def flatten_handlers(cls):
|
||||
def flatten_handlers(cls: Type[Message]) -> Type[Message]:
|
||||
prefix = len('_handle_')
|
||||
handlers = [
|
||||
(key[prefix:], value)
|
||||
@@ -1036,7 +1037,7 @@ class Message(Hashable):
|
||||
)
|
||||
|
||||
@utils.cached_slot_property('_cs_system_content')
|
||||
def system_content(self):
|
||||
def system_content(self) -> Optional[str]:
|
||||
r""":class:`str`: A property that returns the content that is rendered
|
||||
regardless of the :attr:`Message.type`.
|
||||
|
||||
@@ -1657,7 +1658,7 @@ class Message(Hashable):
|
||||
)
|
||||
return Thread(guild=self.guild, state=self._state, data=data)
|
||||
|
||||
async def reply(self, content: Optional[str] = None, **kwargs) -> Message:
|
||||
async def reply(self, content: Optional[str] = None, **kwargs: Any) -> Message:
|
||||
"""|coro|
|
||||
|
||||
A shortcut method to :meth:`.abc.Messageable.send` to reply to the
|
||||
@@ -1798,7 +1799,7 @@ class PartialMessage(Hashable):
|
||||
|
||||
# Also needed for duck typing purposes
|
||||
# n.b. not exposed
|
||||
pinned = property(None, lambda x, y: None)
|
||||
pinned: Any = property(None, lambda x, y: None)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<PartialMessage id={self.id} channel={self.channel!r}>'
|
||||
|
Reference in New Issue
Block a user