From 19fb8ac44703daf3198dd4572b5120fcbfadc51f Mon Sep 17 00:00:00 2001 From: lightningyx <98954380+lightningyx@users.noreply.github.com> Date: Tue, 19 Apr 2022 22:46:38 +0200 Subject: [PATCH] Add narrowed overloads for edit methods on channels --- discord/channel.py | 70 +++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/discord/channel.py b/discord/channel.py index 55ce604eb..236398769 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -257,6 +257,14 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): """ return self._state._get_message(self.last_message_id) if self.last_message_id else None + @overload + async def edit(self) -> Optional[TextChannel]: + ... + + @overload + async def edit(self, *, position: int, reason: Optional[str] = ...) -> None: + ... + @overload async def edit( self, @@ -272,11 +280,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): default_auto_archive_duration: ThreadArchiveDuration = ..., type: ChannelType = ..., overwrites: Mapping[Union[Role, Member, Snowflake], PermissionOverwrite] = ..., - ) -> Optional[TextChannel]: - ... - - @overload - async def edit(self) -> Optional[TextChannel]: + ) -> TextChannel: ... async def edit(self, *, reason: Optional[str] = None, **options: Any) -> Optional[TextChannel]: @@ -1288,6 +1292,14 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel): async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> VoiceChannel: return await self._clone_impl({'bitrate': self.bitrate, 'user_limit': self.user_limit}, name=name, reason=reason) + @overload + async def edit(self) -> None: + ... + + @overload + async def edit(self, *, position: int, reason: Optional[str] = ...) -> None: + ... + @overload async def edit( self, @@ -1303,11 +1315,7 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel): rtc_region: Optional[str] = ..., video_quality_mode: VideoQualityMode = ..., reason: Optional[str] = ..., - ) -> Optional[VoiceChannel]: - ... - - @overload - async def edit(self) -> Optional[VoiceChannel]: + ) -> VoiceChannel: ... async def edit(self, *, reason: Optional[str] = None, **options: Any) -> Optional[VoiceChannel]: @@ -1582,6 +1590,14 @@ class StageChannel(VocalGuildChannel): data = await self._state.http.get_stage_instance(self.id) return StageInstance(guild=self.guild, state=self._state, data=data) + @overload + async def edit(self) -> None: + ... + + @overload + async def edit(self, *, position: int, reason: Optional[str] = ...) -> None: + ... + @overload async def edit( self, @@ -1595,11 +1611,7 @@ class StageChannel(VocalGuildChannel): rtc_region: Optional[str] = ..., video_quality_mode: VideoQualityMode = ..., reason: Optional[str] = ..., - ) -> Optional[StageChannel]: - ... - - @overload - async def edit(self) -> Optional[StageChannel]: + ) -> StageChannel: ... async def edit(self, *, reason: Optional[str] = None, **options: Any) -> Optional[StageChannel]: @@ -1749,6 +1761,14 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable): async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> CategoryChannel: return await self._clone_impl({'nsfw': self.nsfw}, name=name, reason=reason) + @overload + async def edit(self) -> None: + ... + + @overload + async def edit(self, *, position: int, reason: Optional[str] = ...) -> None: + ... + @overload async def edit( self, @@ -1758,11 +1778,7 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable): nsfw: bool = ..., overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = ..., reason: Optional[str] = ..., - ) -> Optional[CategoryChannel]: - ... - - @overload - async def edit(self) -> Optional[CategoryChannel]: + ) -> CategoryChannel: ... async def edit(self, *, reason: Optional[str] = None, **options: Any) -> Optional[CategoryChannel]: @@ -2032,6 +2048,14 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): {'topic': self.topic, 'nsfw': self.nsfw, 'rate_limit_per_user': self.slowmode_delay}, name=name, reason=reason ) + @overload + async def edit(self) -> None: + ... + + @overload + async def edit(self, *, position: int, reason: Optional[str] = ...) -> None: + ... + @overload async def edit( self, @@ -2047,11 +2071,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): default_auto_archive_duration: ThreadArchiveDuration = ..., type: ChannelType = ..., overwrites: Mapping[Union[Role, Member, Snowflake], PermissionOverwrite] = ..., - ) -> Optional[ForumChannel]: - ... - - @overload - async def edit(self) -> Optional[ForumChannel]: + ) -> ForumChannel: ... async def edit(self, *, reason: Optional[str] = None, **options: Any) -> Optional[ForumChannel]: