mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-07 02:21:54 +00:00
Fix remaining type errors in main package
This doesn't fix the type errors in the ext packages though.
This commit is contained in:
parent
3e90664cf9
commit
8d52ddaff6
@ -736,7 +736,7 @@ class DiscordWebSocket:
|
|||||||
async def voice_state(
|
async def voice_state(
|
||||||
self,
|
self,
|
||||||
guild_id: int,
|
guild_id: int,
|
||||||
channel_id: int,
|
channel_id: Optional[int],
|
||||||
self_mute: bool = False,
|
self_mute: bool = False,
|
||||||
self_deaf: bool = False,
|
self_deaf: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -182,8 +182,8 @@ class Attachment(Hashable):
|
|||||||
self.height: Optional[int] = data.get('height')
|
self.height: Optional[int] = data.get('height')
|
||||||
self.width: Optional[int] = data.get('width')
|
self.width: Optional[int] = data.get('width')
|
||||||
self.filename: str = data['filename']
|
self.filename: str = data['filename']
|
||||||
self.url: str = data.get('url')
|
self.url: str = data['url']
|
||||||
self.proxy_url: str = data.get('proxy_url')
|
self.proxy_url: str = data['proxy_url']
|
||||||
self._http = state.http
|
self._http = state.http
|
||||||
self.content_type: Optional[str] = data.get('content_type')
|
self.content_type: Optional[str] = data.get('content_type')
|
||||||
self.description: Optional[str] = data.get('description')
|
self.description: Optional[str] = data.get('description')
|
||||||
@ -483,13 +483,13 @@ class MessageReference:
|
|||||||
return f'<MessageReference message_id={self.message_id!r} channel_id={self.channel_id!r} guild_id={self.guild_id!r}>'
|
return f'<MessageReference message_id={self.message_id!r} channel_id={self.channel_id!r} guild_id={self.guild_id!r}>'
|
||||||
|
|
||||||
def to_dict(self) -> MessageReferencePayload:
|
def to_dict(self) -> MessageReferencePayload:
|
||||||
result: MessageReferencePayload = {'message_id': self.message_id} if self.message_id is not None else {}
|
result: Dict[str, Any] = {'message_id': self.message_id} if self.message_id is not None else {}
|
||||||
result['channel_id'] = self.channel_id
|
result['channel_id'] = self.channel_id
|
||||||
if self.guild_id is not None:
|
if self.guild_id is not None:
|
||||||
result['guild_id'] = self.guild_id
|
result['guild_id'] = self.guild_id
|
||||||
if self.fail_if_not_exists is not None:
|
if self.fail_if_not_exists is not None:
|
||||||
result['fail_if_not_exists'] = self.fail_if_not_exists
|
result['fail_if_not_exists'] = self.fail_if_not_exists
|
||||||
return result
|
return result # type: ignore - Type checker doesn't understand these are the same.
|
||||||
|
|
||||||
to_message_reference_dict = to_dict
|
to_message_reference_dict = to_dict
|
||||||
|
|
||||||
@ -718,7 +718,7 @@ class Message(Hashable):
|
|||||||
# Right now the channel IDs match but maybe in the future they won't.
|
# Right now the channel IDs match but maybe in the future they won't.
|
||||||
if ref.channel_id == channel.id:
|
if ref.channel_id == channel.id:
|
||||||
chan = channel
|
chan = channel
|
||||||
elif isinstance(channel, Thread) and channel.parent.id == ref.channel_id:
|
elif isinstance(channel, Thread) and channel.parent_id == ref.channel_id:
|
||||||
chan = channel
|
chan = channel
|
||||||
else:
|
else:
|
||||||
chan, _ = state._get_guild_channel(resolved, ref.guild_id)
|
chan, _ = state._get_guild_channel(resolved, ref.guild_id)
|
||||||
|
@ -72,7 +72,7 @@ if TYPE_CHECKING:
|
|||||||
from .types.snowflake import Snowflake
|
from .types.snowflake import Snowflake
|
||||||
from .types.activity import Activity as ActivityPayload
|
from .types.activity import Activity as ActivityPayload
|
||||||
from .types.channel import DMChannel as DMChannelPayload
|
from .types.channel import DMChannel as DMChannelPayload
|
||||||
from .types.user import User as UserPayload
|
from .types.user import User as UserPayload, PartialUser as PartialUserPayload
|
||||||
from .types.emoji import Emoji as EmojiPayload
|
from .types.emoji import Emoji as EmojiPayload
|
||||||
from .types.sticker import GuildSticker as GuildStickerPayload
|
from .types.sticker import GuildSticker as GuildStickerPayload
|
||||||
from .types.guild import Guild as GuildPayload
|
from .types.guild import Guild as GuildPayload
|
||||||
@ -314,7 +314,7 @@ class ConnectionState:
|
|||||||
for vc in self.voice_clients:
|
for vc in self.voice_clients:
|
||||||
vc.main_ws = ws # type: ignore - Silencing the unknown attribute (ok at runtime).
|
vc.main_ws = ws # type: ignore - Silencing the unknown attribute (ok at runtime).
|
||||||
|
|
||||||
def store_user(self, data):
|
def store_user(self, data: Union[UserPayload, PartialUserPayload]) -> User:
|
||||||
# this way is 300% faster than `dict.setdefault`.
|
# this way is 300% faster than `dict.setdefault`.
|
||||||
user_id = int(data['id'])
|
user_id = int(data['id'])
|
||||||
try:
|
try:
|
||||||
@ -328,7 +328,7 @@ class ConnectionState:
|
|||||||
def store_user_no_intents(self, data):
|
def store_user_no_intents(self, data):
|
||||||
return User(state=self, data=data)
|
return User(state=self, data=data)
|
||||||
|
|
||||||
def create_user(self, data: UserPayload) -> User:
|
def create_user(self, data: Union[UserPayload, PartialUserPayload]) -> User:
|
||||||
return User(state=self, data=data)
|
return User(state=self, data=data)
|
||||||
|
|
||||||
def get_user(self, id):
|
def get_user(self, id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user