Browse Source

Fix type issues

pull/10109/head
dolfies 2 years ago
parent
commit
29a9f5d018
  1. 5
      discord/abc.py
  2. 4
      discord/channel.py
  3. 2
      discord/guild.py
  4. 3
      discord/voice_client.py

5
discord/abc.py

@ -105,6 +105,7 @@ if TYPE_CHECKING:
)
MessageableChannel = Union[TextChannel, VoiceChannel, StageChannel, Thread, DMChannel, PartialMessageable, GroupChannel]
VocalChannel = Union[VoiceChannel, StageChannel, DMChannel, GroupChannel]
SnowflakeTime = Union["Snowflake", datetime]
MISSING = utils.MISSING
@ -2115,7 +2116,7 @@ class Connectable(Protocol):
*,
timeout: float = 60.0,
reconnect: bool = True,
cls: Callable[[Client, Connectable], T] = VoiceClient,
cls: Callable[[Client, VocalChannel], T] = VoiceClient,
_channel: Optional[Connectable] = None,
self_deaf: bool = False,
self_mute: bool = False,
@ -2168,7 +2169,7 @@ class Connectable(Protocol):
if state._get_voice_client(key_id):
raise ClientException('Already connected to a voice channel')
voice: T = cls(state.client, self)
voice: T = cls(state.client, channel)
if not isinstance(voice, VoiceProtocol):
raise TypeError('Type must meet VoiceProtocol abstract base class')

4
discord/channel.py

@ -3023,7 +3023,7 @@ class DMChannel(discord.abc.Messageable, discord.abc.Connectable, discord.abc.Pr
*,
timeout: float = 60.0,
reconnect: bool = True,
cls: Callable[[Client, discord.abc.Connectable], T] = VoiceClient,
cls: Callable[[Client, discord.abc.VocalChannel], T] = VoiceClient,
ring: bool = True,
) -> T:
"""|coro|
@ -3555,7 +3555,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, discord.abc
*,
timeout: float = 60.0,
reconnect: bool = True,
cls: Callable[[Client, discord.abc.Connectable], T] = VoiceClient,
cls: Callable[[Client, discord.abc.VocalChannel], T] = VoiceClient,
ring: bool = True,
) -> T:
await self._get_channel()

2
discord/guild.py

@ -491,7 +491,7 @@ class Guild(Hashable):
for c in guild.get('channels', []):
factory, _ = _guild_channel_factory(c['type'])
if factory:
self._add_channel(factory(guild=self, data=c, state=state))
self._add_channel(factory(guild=self, data=c, state=state)) # type: ignore
for t in guild.get('threads', []):
self._add_thread(Thread(guild=self, state=self._state, data=t))

3
discord/voice_client.py

@ -59,7 +59,6 @@ if TYPE_CHECKING:
from .state import ConnectionState
from .user import ClientUser
from .opus import Encoder
from .channel import StageChannel, VoiceChannel, DMChannel, GroupChannel
from . import abc
from .types.voice import (
@ -68,7 +67,7 @@ if TYPE_CHECKING:
SupportedModes,
)
VocalChannel = Union[VoiceChannel, StageChannel, DMChannel, GroupChannel]
VocalChannel = abc.VocalChannel
has_nacl: bool

Loading…
Cancel
Save