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

@@ -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