Fix typing issues and improve typing completeness across the library

Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
This commit is contained in:
Stocker
2022-03-13 23:52:10 -04:00
committed by GitHub
parent 603681940f
commit 5aa696ccfa
66 changed files with 1071 additions and 802 deletions

View File

@ -25,13 +25,15 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING, Optional, Type
from typing import TYPE_CHECKING, Optional, Type, TypeVar
if TYPE_CHECKING:
from .abc import Messageable
from types import TracebackType
BE = TypeVar('BE', bound=BaseException)
# fmt: off
__all__ = (
'Typing',
@ -67,13 +69,13 @@ class Typing:
async def __aenter__(self) -> None:
self._channel = channel = await self.messageable._get_channel()
await channel._state.http.send_typing(channel.id)
self.task: asyncio.Task = self.loop.create_task(self.do_typing())
self.task: asyncio.Task[None] = self.loop.create_task(self.do_typing())
self.task.add_done_callback(_typing_done_callback)
async def __aexit__(
self,
exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
exc_type: Optional[Type[BE]],
exc: Optional[BE],
traceback: Optional[TracebackType],
) -> None:
self.task.cancel()