Browse Source

Fix Connectable.connect typing having bad inference if cls is missing

pull/10109/head
Rapptz 3 years ago
committed by dolfies
parent
commit
83de745dae
  1. 8
      discord/abc.py

8
discord/abc.py

@ -2083,7 +2083,7 @@ class Connectable(Protocol):
*, *,
timeout: float = 60.0, timeout: float = 60.0,
reconnect: bool = True, reconnect: bool = True,
cls: Callable[[Client, Connectable], T] = MISSING, cls: Callable[[Client, Connectable], T] = VoiceClient,
_channel: Optional[Connectable] = None, _channel: Optional[Connectable] = None,
self_deaf: bool = False, self_deaf: bool = False,
self_mute: bool = False, self_mute: bool = False,
@ -2136,11 +2136,7 @@ class Connectable(Protocol):
if state._get_voice_client(key_id): if state._get_voice_client(key_id):
raise ClientException('Already connected to a voice channel') raise ClientException('Already connected to a voice channel')
if cls is MISSING: voice: T = cls(state.client, self)
cls = VoiceClient # type: ignore
# The type checker doesn't understand that VoiceClient *is* T here.
voice: T = cls(state.client, channel)
if not isinstance(voice, VoiceProtocol): if not isinstance(voice, VoiceProtocol):
raise TypeError('Type must meet VoiceProtocol abstract base class') raise TypeError('Type must meet VoiceProtocol abstract base class')

Loading…
Cancel
Save