mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-31 13:32:57 +00:00 
			
		
		
		
	Handle type-errors in upcoming pyright release
This commit is contained in:
		| @@ -185,7 +185,7 @@ class Embed: | ||||
|         type: EmbedType = 'rich', | ||||
|         url: MaybeEmpty[Any] = EmptyEmbed, | ||||
|         description: MaybeEmpty[Any] = EmptyEmbed, | ||||
|         timestamp: datetime.datetime = None, | ||||
|         timestamp: MaybeEmpty[datetime.datetime] = EmptyEmbed, | ||||
|     ): | ||||
|  | ||||
|         self.colour = colour if colour is not EmptyEmbed else color | ||||
| @@ -203,7 +203,7 @@ class Embed: | ||||
|         if self.url is not EmptyEmbed: | ||||
|             self.url = str(self.url) | ||||
|  | ||||
|         if timestamp: | ||||
|         if timestamp is not EmptyEmbed: | ||||
|             self.timestamp = timestamp | ||||
|  | ||||
|     @classmethod | ||||
|   | ||||
| @@ -416,9 +416,9 @@ async def convert_flag(ctx, argument: str, flag: Flag, annotation: Any = None) - | ||||
|             # typing.List[x] | ||||
|             annotation = annotation.__args__[0] | ||||
|             return await convert_flag(ctx, argument, flag, annotation) | ||||
|         elif origin is Union and annotation.__args__[-1] is type(None): | ||||
|         elif origin is Union and type(None) in annotation.__args__: | ||||
|             # typing.Optional[x] | ||||
|             annotation = Union[annotation.__args__[:-1]] | ||||
|             annotation = Union[tuple(arg for arg in annotation.__args__ if arg is not type(None))]  # type: ignore | ||||
|             return await run_converters(ctx, annotation, argument, param) | ||||
|         elif origin is dict: | ||||
|             # typing.Dict[K, V] -> typing.Tuple[K, V] | ||||
|   | ||||
| @@ -38,6 +38,7 @@ import io | ||||
|  | ||||
| from typing import Any, Callable, Generic, IO, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union | ||||
|  | ||||
| from .enums import SpeakingState | ||||
| from .errors import ClientException | ||||
| from .opus import Encoder as OpusEncoder | ||||
| from .oggparse import OggStream | ||||
| @@ -656,7 +657,7 @@ class AudioPlayer(threading.Thread): | ||||
|  | ||||
|         # getattr lookup speed ups | ||||
|         play_audio = self.client.send_audio_packet | ||||
|         self._speak(True) | ||||
|         self._speak(SpeakingState.voice) | ||||
|  | ||||
|         while not self._end.is_set(): | ||||
|             # are we paused? | ||||
| @@ -714,19 +715,19 @@ class AudioPlayer(threading.Thread): | ||||
|     def stop(self) -> None: | ||||
|         self._end.set() | ||||
|         self._resumed.set() | ||||
|         self._speak(False) | ||||
|         self._speak(SpeakingState.none) | ||||
|  | ||||
|     def pause(self, *, update_speaking: bool = True) -> None: | ||||
|         self._resumed.clear() | ||||
|         if update_speaking: | ||||
|             self._speak(False) | ||||
|             self._speak(SpeakingState.none) | ||||
|  | ||||
|     def resume(self, *, update_speaking: bool = True) -> None: | ||||
|         self.loops = 0 | ||||
|         self._start = time.perf_counter() | ||||
|         self._resumed.set() | ||||
|         if update_speaking: | ||||
|             self._speak(True) | ||||
|             self._speak(SpeakingState.voice) | ||||
|  | ||||
|     def is_playing(self) -> bool: | ||||
|         return self._resumed.is_set() and not self._end.is_set() | ||||
| @@ -740,7 +741,7 @@ class AudioPlayer(threading.Thread): | ||||
|             self.source = source | ||||
|             self.resume(update_speaking=False) | ||||
|  | ||||
|     def _speak(self, speaking: bool) -> None: | ||||
|     def _speak(self, speaking: SpeakingState) -> None: | ||||
|         try: | ||||
|             asyncio.run_coroutine_threadsafe(self.client.ws.speak(speaking), self.client.loop) | ||||
|         except Exception as e: | ||||
|   | ||||
| @@ -481,7 +481,7 @@ class AutoShardedClient(Client): | ||||
|         *, | ||||
|         activity: Optional[BaseActivity] = None, | ||||
|         status: Optional[Status] = None, | ||||
|         shard_id: int = None, | ||||
|         shard_id: Optional[int] = None, | ||||
|     ) -> None: | ||||
|         """|coro| | ||||
|  | ||||
|   | ||||
| @@ -563,7 +563,7 @@ class VoiceClient(VoiceProtocol): | ||||
|  | ||||
|         return header + box.encrypt(bytes(data), bytes(nonce)).ciphertext + nonce[:4] | ||||
|  | ||||
|     def play(self, source: AudioSource, *, after: Callable[[Optional[Exception]], Any] = None) -> None: | ||||
|     def play(self, source: AudioSource, *, after: Optional[Callable[[Optional[Exception]], Any]] = None) -> None: | ||||
|         """Plays an :class:`AudioSource`. | ||||
|  | ||||
|         The finalizer, ``after`` is called after the source has been exhausted | ||||
|   | ||||
		Reference in New Issue
	
	Block a user