mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-21 00:07:51 +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(
|
||||
self,
|
||||
guild_id: int,
|
||||
channel_id: int,
|
||||
channel_id: Optional[int],
|
||||
self_mute: bool = False,
|
||||
self_deaf: bool = False,
|
||||
) -> None:
|
||||
|
@ -182,8 +182,8 @@ class Attachment(Hashable):
|
||||
self.height: Optional[int] = data.get('height')
|
||||
self.width: Optional[int] = data.get('width')
|
||||
self.filename: str = data['filename']
|
||||
self.url: str = data.get('url')
|
||||
self.proxy_url: str = data.get('proxy_url')
|
||||
self.url: str = data['url']
|
||||
self.proxy_url: str = data['proxy_url']
|
||||
self._http = state.http
|
||||
self.content_type: Optional[str] = data.get('content_type')
|
||||
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}>'
|
||||
|
||||
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
|
||||
if self.guild_id is not None:
|
||||
result['guild_id'] = self.guild_id
|
||||
if self.fail_if_not_exists is not None:
|
||||
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
|
||||
|
||||
@ -718,7 +718,7 @@ class Message(Hashable):
|
||||
# Right now the channel IDs match but maybe in the future they won't.
|
||||
if ref.channel_id == channel.id:
|
||||
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
|
||||
else:
|
||||
chan, _ = state._get_guild_channel(resolved, ref.guild_id)
|
||||
|
@ -72,7 +72,7 @@ if TYPE_CHECKING:
|
||||
from .types.snowflake import Snowflake
|
||||
from .types.activity import Activity as ActivityPayload
|
||||
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.sticker import GuildSticker as GuildStickerPayload
|
||||
from .types.guild import Guild as GuildPayload
|
||||
@ -314,7 +314,7 @@ class ConnectionState:
|
||||
for vc in self.voice_clients:
|
||||
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`.
|
||||
user_id = int(data['id'])
|
||||
try:
|
||||
@ -328,7 +328,7 @@ class ConnectionState:
|
||||
def store_user_no_intents(self, 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)
|
||||
|
||||
def get_user(self, id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user