diff --git a/discord/client.py b/discord/client.py index 3b897dfff..07d86703f 100644 --- a/discord/client.py +++ b/discord/client.py @@ -77,7 +77,6 @@ from .threads import Thread from .sticker import GuildSticker, StandardSticker, StickerPack, _sticker_factory if TYPE_CHECKING: - from typing_extensions import Self from .types.guild import Guild as GuildPayload from .abc import SnowflakeTime, Snowflake, PrivateChannel from .guild import GuildChannel @@ -255,7 +254,7 @@ class Client: } self._enable_debug_events: bool = options.pop('enable_debug_events', False) - self._connection: ConnectionState[Self] = self._get_state(**options) + self._connection: ConnectionState = self._get_state(**options) self._connection.shard_count = self.shard_count self._closed: bool = False self._ready: asyncio.Event = asyncio.Event() diff --git a/discord/interactions.py b/discord/interactions.py index b952cffc6..d2c6bfd58 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -71,10 +71,9 @@ if TYPE_CHECKING: ] MISSING: Any = utils.MISSING -ClientT = TypeVar('ClientT', bound='Client') -class Interaction(Generic[ClientT]): +class Interaction: """Represents a Discord interaction. An interaction happens when a user does an action that needs to @@ -126,9 +125,9 @@ class Interaction(Generic[ClientT]): '_cs_channel', ) - def __init__(self, *, data: InteractionPayload, state: ConnectionState[ClientT]): - self._state: ConnectionState[ClientT] = state - self._client: ClientT = state._get_client() + def __init__(self, *, data: InteractionPayload, state: ConnectionState): + self._state: ConnectionState = state + self._client: Client = state._get_client() self._session: ClientSession = state.http._HTTPClient__session # type: ignore - Mangled attribute for __session self._original_message: Optional[InteractionMessage] = None self._from_data(data) @@ -171,7 +170,7 @@ class Interaction(Generic[ClientT]): pass @property - def client(self) -> ClientT: + def client(self) -> Client: """:class:`Client`: The client that is handling this interaction.""" return self._client diff --git a/discord/shard.py b/discord/shard.py index 923647763..9093b9c56 100644 --- a/discord/shard.py +++ b/discord/shard.py @@ -46,7 +46,6 @@ from .enums import Status from typing import TYPE_CHECKING, Any, Callable, Tuple, Type, Optional, List, Dict if TYPE_CHECKING: - from typing_extensions import Self from .gateway import DiscordWebSocket from .activity import BaseActivity from .enums import Status @@ -317,7 +316,7 @@ class AutoShardedClient(Client): """ if TYPE_CHECKING: - _connection: AutoShardedConnectionState[Self] + _connection: AutoShardedConnectionState def __init__(self, *args: Any, loop: Optional[asyncio.AbstractEventLoop] = None, **kwargs: Any) -> None: kwargs.pop('shard_id', None) diff --git a/discord/state.py b/discord/state.py index f23a8402f..e3baa1d10 100644 --- a/discord/state.py +++ b/discord/state.py @@ -98,8 +98,6 @@ if TYPE_CHECKING: T = TypeVar('T') Channel = Union[GuildChannel, VocalGuildChannel, PrivateChannel, PartialMessageable] -ClientT = TypeVar('ClientT', bound='Client') - class ChunkRequest: def __init__( @@ -159,10 +157,10 @@ async def logging_coroutine(coroutine: Coroutine[Any, Any, T], *, info: str) -> _log.exception('Exception occurred during %s', info) -class ConnectionState(Generic[ClientT]): +class ConnectionState: if TYPE_CHECKING: _get_websocket: Callable[..., DiscordWebSocket] - _get_client: Callable[..., ClientT] + _get_client: Callable[..., Client] _parsers: Dict[str, Callable[[Dict[str, Any]], None]] def __init__( @@ -1487,7 +1485,7 @@ class ConnectionState(Generic[ClientT]): return Message(state=self, channel=channel, data=data) -class AutoShardedConnectionState(ConnectionState[ClientT]): +class AutoShardedConnectionState(ConnectionState): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.shard_ids: Union[List[int], range] = []