Make mypy happy
This commit is contained in:
parent
47a8014b4c
commit
500d91a14c
2 changed files with 26 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Awaitable, Callable
|
from typing import Any, Awaitable, Callable, Dict, Optional
|
||||||
|
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
|
|
@ -98,13 +98,14 @@ class Connection:
|
||||||
self._connected_condition = asyncio.Condition()
|
self._connected_condition = asyncio.Condition()
|
||||||
self._disconnected_condition = asyncio.Condition()
|
self._disconnected_condition = asyncio.Condition()
|
||||||
|
|
||||||
self._event_loop = None
|
self._event_loop: Optional[asyncio.Task[None]] = None
|
||||||
|
|
||||||
# These must always be (re)set together. If one of them is None, all
|
# These must always be (re)set together. If one of them is None, all
|
||||||
# must be None.
|
# must be None.
|
||||||
self._ws = None
|
self._ws = None
|
||||||
self._awaiting_replies = None
|
self._awaiting_replies: Optional[Dict[str, Callable[...,
|
||||||
self._ping_check = None
|
Awaitable[None]]]] = None
|
||||||
|
self._ping_check: Optional[asyncio.Task[None]] = None
|
||||||
|
|
||||||
def register_event(self,
|
def register_event(self,
|
||||||
event: str,
|
event: str,
|
||||||
|
|
@ -164,7 +165,7 @@ class Connection:
|
||||||
except websockets.InvalidStatusCode:
|
except websockets.InvalidStatusCode:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def _disconnect_in(self, delay):
|
async def _disconnect_in(self, delay: int) -> None:
|
||||||
await asyncio.sleep(delay)
|
await asyncio.sleep(delay)
|
||||||
await self._disconnect()
|
await self._disconnect()
|
||||||
|
|
||||||
|
|
@ -265,8 +266,10 @@ class Connection:
|
||||||
|
|
||||||
await self._disconnect()
|
await self._disconnect()
|
||||||
|
|
||||||
await self._event_loop
|
# We know that _event_loop is not None, but this is to keep mypy happy.
|
||||||
self._event_loop = None
|
if self._event_loop is not None:
|
||||||
|
await self._event_loop
|
||||||
|
self._event_loop = None
|
||||||
|
|
||||||
self._state = self._NOT_RUNNING
|
self._state = self._NOT_RUNNING
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,19 @@
|
||||||
__all__ = ["EuphException", "JoinException", "CouldNotConnectException",
|
__all__ = [
|
||||||
"CouldNotAuthenticateException", "RoomClosedException",
|
"EuphException",
|
||||||
"RateLimitException", "NotLoggedInException", "UnauthorizedException"]
|
# Connection stuff
|
||||||
|
"IncorrectStateException",
|
||||||
|
"ConnectionClosedException",
|
||||||
|
# Joining a room
|
||||||
|
"JoinException",
|
||||||
|
"CouldNotConnectException",
|
||||||
|
"CouldNotAuthenticateException",
|
||||||
|
# Doing stuff in a room
|
||||||
|
"RoomClosedException",
|
||||||
|
# Other stuff
|
||||||
|
"RateLimitException",
|
||||||
|
"NotLoggedInException",
|
||||||
|
"UnauthorizedException",
|
||||||
|
]
|
||||||
|
|
||||||
class EuphException(Exception):
|
class EuphException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue