Use typing.Self throughout library

This commit is contained in:
Josh
2022-03-01 22:53:24 +10:00
committed by GitHub
parent a90e1824f4
commit 147948af9b
28 changed files with 212 additions and 191 deletions

View File

@@ -70,6 +70,8 @@ __all__ = (
T = TypeVar('T', bound=VoiceProtocol)
if TYPE_CHECKING:
from typing_extensions import Self
from .client import Client
from .user import ClientUser
from .asset import Asset
@@ -216,9 +218,6 @@ class _Overwrites:
return self.type == 1
GCH = TypeVar('GCH', bound='GuildChannel')
class GuildChannel:
"""An ABC that details the common operations on a Discord guild channel.
@@ -817,12 +816,12 @@ class GuildChannel:
raise TypeError('Invalid overwrite type provided.')
async def _clone_impl(
self: GCH,
self,
base_attrs: Dict[str, Any],
*,
name: Optional[str] = None,
reason: Optional[str] = None,
) -> GCH:
) -> Self:
base_attrs['permission_overwrites'] = [x._asdict() for x in self._overwrites]
base_attrs['parent_id'] = self.category_id
base_attrs['name'] = name or self.name
@@ -835,7 +834,7 @@ class GuildChannel:
self.guild._channels[obj.id] = obj # type: ignore - obj is a GuildChannel
return obj
async def clone(self: GCH, *, name: Optional[str] = None, reason: Optional[str] = None) -> GCH:
async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> Self:
"""|coro|
Clones this channel. This creates a channel with the same properties