Remove generic from Interaction and ConnectionState

This results in poor ergonomics due to the lack of default generics
for the common case. For most users this ends up in a degraded
experience since the type will resolve to Unknown rather than at the
very least a Client.
This commit is contained in:
Rapptz
2022-03-05 05:03:23 -05:00
parent aa74238053
commit f7315573aa
4 changed files with 10 additions and 15 deletions

View File

@@ -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] = []