mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Fix and document type ignores in client
This commit is contained in:
parent
6c2ea4f0a0
commit
51b79411e3
@ -366,7 +366,7 @@ class Client:
|
|||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
"""
|
"""
|
||||||
return self._connection.application_flags # type: ignore
|
return self._connection.application_flags
|
||||||
|
|
||||||
def is_ready(self) -> bool:
|
def is_ready(self) -> bool:
|
||||||
""":class:`bool`: Specifies if the client's internal cache is ready for use."""
|
""":class:`bool`: Specifies if the client's internal cache is ready for use."""
|
||||||
@ -795,7 +795,7 @@ class Client:
|
|||||||
Optional[Union[:class:`.abc.GuildChannel`, :class:`.Thread`, :class:`.abc.PrivateChannel`]]
|
Optional[Union[:class:`.abc.GuildChannel`, :class:`.Thread`, :class:`.abc.PrivateChannel`]]
|
||||||
The returned channel or ``None`` if not found.
|
The returned channel or ``None`` if not found.
|
||||||
"""
|
"""
|
||||||
return self._connection.get_channel(id)
|
return self._connection.get_channel(id) # type: ignore - The cache contains all channel types
|
||||||
|
|
||||||
def get_partial_messageable(self, id: int, *, type: Optional[ChannelType] = None) -> PartialMessageable:
|
def get_partial_messageable(self, id: int, *, type: Optional[ChannelType] = None) -> PartialMessageable:
|
||||||
"""Returns a partial messageable with the given channel ID.
|
"""Returns a partial messageable with the given channel ID.
|
||||||
@ -1154,7 +1154,7 @@ class Client:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if activity is not None:
|
if activity is not None:
|
||||||
me.activities = (activity,)
|
me.activities = (activity,) # type: ignore - Type checker does not understand the downcast here
|
||||||
else:
|
else:
|
||||||
me.activities = ()
|
me.activities = ()
|
||||||
|
|
||||||
@ -1251,11 +1251,11 @@ class Client:
|
|||||||
if isinstance(after, datetime.datetime):
|
if isinstance(after, datetime.datetime):
|
||||||
after = Object(id=time_snowflake(after, high=True))
|
after = Object(id=time_snowflake(after, high=True))
|
||||||
|
|
||||||
predicate = None
|
predicate: Optional[Callable[[GuildPayload], bool]] = None
|
||||||
strategy, state = _before_strategy, before
|
strategy, state = _before_strategy, before
|
||||||
|
|
||||||
if before and after:
|
if before and after:
|
||||||
predicate = lambda m: int(m['id']) > after.id # type: ignore
|
predicate = lambda m: int(m['id']) > after.id
|
||||||
elif after:
|
elif after:
|
||||||
strategy, state = _after_strategy, after
|
strategy, state = _after_strategy, after
|
||||||
|
|
||||||
@ -1425,6 +1425,7 @@ class Client:
|
|||||||
"""
|
"""
|
||||||
data = await self.http.get_stage_instance(channel_id)
|
data = await self.http.get_stage_instance(channel_id)
|
||||||
guild = self.get_guild(int(data['guild_id']))
|
guild = self.get_guild(int(data['guild_id']))
|
||||||
|
# Guild can technically be None here but this is being explicitly silenced right now.
|
||||||
return StageInstance(guild=guild, state=self._connection, data=data) # type: ignore
|
return StageInstance(guild=guild, state=self._connection, data=data) # type: ignore
|
||||||
|
|
||||||
# Invite management
|
# Invite management
|
||||||
@ -1689,7 +1690,8 @@ class Client:
|
|||||||
The sticker you requested.
|
The sticker you requested.
|
||||||
"""
|
"""
|
||||||
data = await self.http.get_sticker(sticker_id)
|
data = await self.http.get_sticker(sticker_id)
|
||||||
cls, _ = _sticker_factory(data['type']) # type: ignore
|
cls, _ = _sticker_factory(data['type'])
|
||||||
|
# The type checker is not smart enough to figure out the constructor is correct
|
||||||
return cls(state=self._connection, data=data) # type: ignore
|
return cls(state=self._connection, data=data) # type: ignore
|
||||||
|
|
||||||
async def fetch_premium_sticker_packs(self) -> List[StickerPack]:
|
async def fetch_premium_sticker_packs(self) -> List[StickerPack]:
|
||||||
|
@ -61,7 +61,7 @@ class GuildSticker(BaseSticker, _GuildStickerOptional):
|
|||||||
guild_id: Snowflake
|
guild_id: Snowflake
|
||||||
|
|
||||||
|
|
||||||
Sticker = Union[BaseSticker, StandardSticker, GuildSticker]
|
Sticker = Union[StandardSticker, GuildSticker]
|
||||||
|
|
||||||
|
|
||||||
class StickerPack(TypedDict):
|
class StickerPack(TypedDict):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user