Skip to content

Commit 095beb3

Browse files
committed
fix: Typing
1 parent 676da0e commit 095beb3

1 file changed

Lines changed: 93 additions & 90 deletions

File tree

discord/player.py

Lines changed: 93 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import warnings
4040
from math import floor
4141
from typing import IO, TYPE_CHECKING, Any, Callable, Generic, Literal, TypeVar, overload
42-
42+
from collections.abc import Set
4343
from .enums import SpeakingState
4444
from .errors import ClientException
4545
from .oggparse import OggStream
@@ -52,7 +52,6 @@
5252

5353
from .voice import VoiceClient
5454

55-
5655
AT = TypeVar("AT", bound="AudioSource")
5756
FT = TypeVar("FT", bound="FFmpegOpusAudio")
5857

@@ -152,12 +151,12 @@ class FFmpegAudio(AudioSource):
152151
BLOCKSIZE: int = io.DEFAULT_BUFFER_SIZE
153152

154153
def __init__(
155-
self,
156-
source: str | io.BufferedIOBase,
157-
*,
158-
executable: str = "ffmpeg",
159-
args: Any,
160-
**subprocess_kwargs: Any,
154+
self,
155+
source: str | io.BufferedIOBase,
156+
*,
157+
executable: str = "ffmpeg",
158+
args: Any,
159+
**subprocess_kwargs: Any,
161160
):
162161
piping_stdin = subprocess_kwargs.get("stdin") == subprocess.PIPE
163162
if piping_stdin and isinstance(source, str):
@@ -309,7 +308,7 @@ def cleanup(self) -> None:
309308
self._process = self._stdout = self._stdin = self._stderr = MISSING
310309

311310

312-
DEFAULT_PROTOCOL_WHITELIST: set[str] = frozenset(
311+
DEFAULT_PROTOCOL_WHITELIST: Set[str] = frozenset(
313312
{"file", "http", "https", "tcp", "tls", "crypto", "pipe", "fd", "cache"}
314313
)
315314

@@ -372,40 +371,42 @@ class FFmpegPCMAudio(FFmpegAudio):
372371

373372
@overload
374373
def __init__(
375-
self,
376-
source: io.BufferedIOBase,
377-
*,
378-
executable: str = ...,
379-
pipe: Literal[True] = ...,
380-
stderr: IO[bytes] | None = ...,
381-
before_options: str | None = ...,
382-
options: str | None = ...,
383-
protocol_whitelist: set[str] | None = ...,
384-
) -> None: ...
374+
self,
375+
source: io.BufferedIOBase,
376+
*,
377+
executable: str = ...,
378+
pipe: Literal[True] = ...,
379+
stderr: IO[bytes] | None = ...,
380+
before_options: str | None = ...,
381+
options: str | None = ...,
382+
protocol_whitelist: Set[str] | None = ...,
383+
) -> None:
384+
...
385385

386386
@overload
387387
def __init__(
388-
self,
389-
source: str,
390-
*,
391-
executable: str = ...,
392-
pipe: Literal[False] = ...,
393-
stderr: IO[bytes] | None = ...,
394-
before_options: str | None = ...,
395-
options: str | None = ...,
396-
protocol_whitelist: set[str] | None = ...,
397-
) -> None: ...
388+
self,
389+
source: str,
390+
*,
391+
executable: str = ...,
392+
pipe: Literal[False] = ...,
393+
stderr: IO[bytes] | None = ...,
394+
before_options: str | None = ...,
395+
options: str | None = ...,
396+
protocol_whitelist: Set[str] | None = ...,
397+
) -> None:
398+
...
398399

399400
def __init__(
400-
self,
401-
source: str | io.BufferedIOBase,
402-
*,
403-
executable: str = "ffmpeg",
404-
pipe: bool = False,
405-
stderr: IO[bytes] | None = None,
406-
before_options: str | None = None,
407-
options: str | None = None,
408-
protocol_whitelist: set[str] | None = DEFAULT_PROTOCOL_WHITELIST,
401+
self,
402+
source: str | io.BufferedIOBase,
403+
*,
404+
executable: str = "ffmpeg",
405+
pipe: bool = False,
406+
stderr: IO[bytes] | None = None,
407+
before_options: str | None = None,
408+
options: str | None = None,
409+
protocol_whitelist: Set[str] | None = DEFAULT_PROTOCOL_WHITELIST,
409410
) -> None:
410411
args = []
411412
subprocess_kwargs = {
@@ -532,46 +533,48 @@ class FFmpegOpusAudio(FFmpegAudio):
532533

533534
@overload
534535
def __init__(
535-
self,
536-
source: io.BufferedIOBase,
537-
*,
538-
bitrate: int | None = None,
539-
codec: str | None = None,
540-
executable: str = ...,
541-
pipe: Literal[True] = ...,
542-
stderr: IO[bytes] | None = ...,
543-
before_options: str | None = ...,
544-
options: str | None = ...,
545-
protocol_whitelist: set[str] | None = ...,
546-
) -> None: ...
536+
self,
537+
source: io.BufferedIOBase,
538+
*,
539+
bitrate: int | None = None,
540+
codec: str | None = None,
541+
executable: str = ...,
542+
pipe: Literal[True] = ...,
543+
stderr: IO[bytes] | None = ...,
544+
before_options: str | None = ...,
545+
options: str | None = ...,
546+
protocol_whitelist: Set[str] | None = ...,
547+
) -> None:
548+
...
547549

548550
@overload
549551
def __init__(
550-
self,
551-
source: str,
552-
*,
553-
bitrate: int | None = None,
554-
codec: str | None = None,
555-
executable: str = ...,
556-
pipe: Literal[False] = ...,
557-
stderr: IO[bytes] | None = ...,
558-
before_options: str | None = ...,
559-
options: str | None = ...,
560-
protocol_whitelist: set[str] | None = ...,
561-
) -> None: ...
552+
self,
553+
source: str,
554+
*,
555+
bitrate: int | None = None,
556+
codec: str | None = None,
557+
executable: str = ...,
558+
pipe: Literal[False] = ...,
559+
stderr: IO[bytes] | None = ...,
560+
before_options: str | None = ...,
561+
options: str | None = ...,
562+
protocol_whitelist: Set[str] | None = ...,
563+
) -> None:
564+
...
562565

563566
def __init__(
564-
self,
565-
source: str | io.BufferedIOBase,
566-
*,
567-
bitrate: int | None = None,
568-
codec: str | None = None,
569-
executable: str = "ffmpeg",
570-
pipe: bool = False,
571-
stderr: IO[bytes] | None = None,
572-
before_options: str | None = None,
573-
options: str | None = None,
574-
protocol_whitelist: set[str] | None = DEFAULT_PROTOCOL_WHITELIST,
567+
self,
568+
source: str | io.BufferedIOBase,
569+
*,
570+
bitrate: int | None = None,
571+
codec: str | None = None,
572+
executable: str = "ffmpeg",
573+
pipe: bool = False,
574+
stderr: IO[bytes] | None = None,
575+
before_options: str | None = None,
576+
options: str | None = None,
577+
protocol_whitelist: Set[str] | None = DEFAULT_PROTOCOL_WHITELIST,
575578
) -> None:
576579
args = []
577580
subprocess_kwargs = {
@@ -626,11 +629,11 @@ def __init__(
626629

627630
@classmethod
628631
async def from_probe(
629-
cls,
630-
source: str,
631-
*,
632-
method: str | Callable[[str, str], tuple[str | None, int | None]] | None = None,
633-
**kwargs: Any,
632+
cls,
633+
source: str,
634+
*,
635+
method: str | Callable[[str, str], tuple[str | None, int | None]] | None = None,
636+
**kwargs: Any,
634637
) -> Self:
635638
r"""|coro|
636639
@@ -693,11 +696,11 @@ def custom_probe(source, executable):
693696

694697
@classmethod
695698
async def probe(
696-
cls,
697-
source: str,
698-
*,
699-
method: str | Callable[[str, str], tuple[str | None, int | None]] | None = None,
700-
executable: str | None = None,
699+
cls,
700+
source: str,
701+
*,
702+
method: str | Callable[[str, str], tuple[str | None, int | None]] | None = None,
703+
executable: str | None = None,
701704
) -> tuple[str | None, int | None]:
702705
"""|coro|
703706
@@ -779,7 +782,7 @@ async def probe(
779782

780783
@staticmethod
781784
def _probe_codec_native(
782-
source, executable: str = "ffmpeg"
785+
source, executable: str = "ffmpeg"
783786
) -> tuple[str | None, int | None]:
784787
exe = (
785788
executable[:2] + "probe"
@@ -812,7 +815,7 @@ def _probe_codec_native(
812815

813816
@staticmethod
814817
def _probe_codec_fallback(
815-
source, executable: str = "ffmpeg"
818+
source, executable: str = "ffmpeg"
816819
) -> tuple[str | None, int | None]:
817820
args = [executable, "-hide_banner", "-i", source]
818821
proc = subprocess.Popen(
@@ -904,11 +907,11 @@ class AudioPlayer(threading.Thread):
904907
DELAY: float = OpusEncoder.FRAME_LENGTH / 1000.0
905908

906909
def __init__(
907-
self,
908-
source: AudioSource,
909-
client: VoiceClient,
910-
*,
911-
after: Callable[[Exception | None], Any] | None = None,
910+
self,
911+
source: AudioSource,
912+
client: VoiceClient,
913+
*,
914+
after: Callable[[Exception | None], Any] | None = None,
912915
) -> None:
913916
super().__init__(daemon=True, name=f"audio-player:{id(self):#x}")
914917
self.source: AudioSource = source

0 commit comments

Comments
 (0)