Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typing): proper VoiceClient.play() return value #2324

Merged
merged 5 commits into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions discord/voice_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -623,13 +623,33 @@ def get_ssrc(self, user_id):
user_id
]

@overload
def play(
self,
source: AudioSource,
*,
after: Callable[[Exception | None], Any] = None,
wait_finish: bool = False,
after: Callable[[Exception | None], Any] | None = None,
wait_finish: Literal[False] = False,
) -> None:
...

@overload
def play(
self,
source: AudioSource,
*,
after: Callable[[Exception | None], Any] | None = None,
wait_finish: Literal[True],
solaluset marked this conversation as resolved.
Show resolved Hide resolved
) -> asyncio.Future:
...

def play(
self,
source: AudioSource,
*,
after: Callable[[Exception | None], Any] | None = None,
wait_finish: bool = False,
) -> None | asyncio.Future:
Dorukyum marked this conversation as resolved.
Show resolved Hide resolved
"""Plays an :class:`AudioSource`.

The finalizer, ``after`` is called after the source has been exhausted
Expand Down
Loading