From ccd47eded63768690e84b0831997c8644cfa372c Mon Sep 17 00:00:00 2001 From: Krutyi 4el <60041069+Krutyi-4el@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:09:29 +0200 Subject: [PATCH 1/5] fix(typing): proper VoiceClient.play() return value --- discord/voice_client.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index 437311122a..c594e5d171 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -46,7 +46,7 @@ import struct import threading import time -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Any, Callable, Literal, overload from . import opus, utils from .backoff import ExponentialBackoff @@ -623,13 +623,31 @@ def get_ssrc(self, user_id): user_id ] + @overload + def play( + self, + source: AudioSource, + *, + after: Callable[[Exception | None], Any] = None, + wait_finish: Literal[False] = False, + ) -> None: ... + + @overload + def play( + self, + source: AudioSource, + *, + after: Callable[[Exception | None], Any] = None, + wait_finish: Literal[True], + ) -> asyncio.Future: ... + def play( self, source: AudioSource, *, after: Callable[[Exception | None], Any] = None, wait_finish: bool = False, - ) -> None: + ) -> None | asyncio.Future: """Plays an :class:`AudioSource`. The finalizer, ``after`` is called after the source has been exhausted From 59a5b2129c503a40c3cc331b12c978b750744389 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:18:02 +0000 Subject: [PATCH 2/5] style(pre-commit): auto fixes from pre-commit.com hooks --- discord/voice_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index c594e5d171..73cf0bc495 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -630,7 +630,8 @@ def play( *, after: Callable[[Exception | None], Any] = None, wait_finish: Literal[False] = False, - ) -> None: ... + ) -> None: + ... @overload def play( @@ -639,7 +640,8 @@ def play( *, after: Callable[[Exception | None], Any] = None, wait_finish: Literal[True], - ) -> asyncio.Future: ... + ) -> asyncio.Future: + ... def play( self, From 8e840f6941b10dead5a8261c10955d90e5036f39 Mon Sep 17 00:00:00 2001 From: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:44:48 +0200 Subject: [PATCH 3/5] fix(typing): mark after as optional Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> --- discord/voice_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index 73cf0bc495..09ad8f5088 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -628,7 +628,7 @@ def play( self, source: AudioSource, *, - after: Callable[[Exception | None], Any] = None, + after: Callable[[Exception | None], Any] | None = None, wait_finish: Literal[False] = False, ) -> None: ... From 5dd91a0ab94aac61c462ce91b38adf4980eae3c7 Mon Sep 17 00:00:00 2001 From: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:45:24 +0200 Subject: [PATCH 4/5] fix(typing): mark after as optional Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> --- discord/voice_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index 09ad8f5088..251a1f155e 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -638,7 +638,7 @@ def play( self, source: AudioSource, *, - after: Callable[[Exception | None], Any] = None, + after: Callable[[Exception | None], Any] | None = None, wait_finish: Literal[True], ) -> asyncio.Future: ... From 05d1d4da874fc50055de4c5479393bcb050f1503 Mon Sep 17 00:00:00 2001 From: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:45:46 +0200 Subject: [PATCH 5/5] fix(typing): mark after as optional Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> --- discord/voice_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/voice_client.py b/discord/voice_client.py index 251a1f155e..61bc0ad9d2 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -647,7 +647,7 @@ def play( self, source: AudioSource, *, - after: Callable[[Exception | None], Any] = None, + after: Callable[[Exception | None], Any] | None = None, wait_finish: bool = False, ) -> None | asyncio.Future: """Plays an :class:`AudioSource`.