From 04f5fcf7418f1964236811d2b25a6ba12c7d5ae2 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 16 May 2022 15:33:41 -0400 Subject: [PATCH] Fix Connectable.connect typing having bad inference if cls is missing --- discord/abc.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index ff1ea0005..7e7ffedfe 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -1814,7 +1814,7 @@ class Connectable(Protocol): *, timeout: float = 60.0, reconnect: bool = True, - cls: Callable[[Client, Connectable], T] = MISSING, + cls: Callable[[Client, Connectable], T] = VoiceClient, self_deaf: bool = False, self_mute: bool = False, ) -> T: @@ -1867,12 +1867,7 @@ class Connectable(Protocol): raise ClientException('Already connected to a voice channel.') client = state._get_client() - - if cls is MISSING: - cls = VoiceClient - - # The type checker doesn't understand that VoiceClient *is* T here. - voice: T = cls(client, self) # type: ignore + voice: T = cls(client, self) if not isinstance(voice, VoiceProtocol): raise TypeError('Type must meet VoiceProtocol abstract base class.')