Typing update

This commit is contained in:
DevilXD committed 2022-07-31 21:40:03 +02:00
1 parent 7a7b94f57c
commit f919850ad2
6 files changed
+10 -10

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ class Channel:
name = self._login
return f"Channel({name}, {self.id})"
def __eq__(self, other: object):
def __eq__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return self.id == other.id
return NotImplemented
+2 -2
View File
@@ -78,7 +78,7 @@ class GQLOperation(JsonType):
if variables is not None:
self.__setitem__("variables", variables)
def with_variables(self, variables: JsonType):
def with_variables(self, variables: JsonType) -> GQLOperation:
modified = copy(self)
if "variables" in self:
existing_variables: JsonType = modified["variables"]
@@ -209,7 +209,7 @@ class WebsocketTopic:
def __repr__(self) -> str:
return f"Topic({self._id})"
def __eq__(self, other):
def __eq__(self, other) -> bool:
if isinstance(other, WebsocketTopic):
return self._id == other._id
elif isinstance(other, str):
+1 -1
View File
@@ -237,7 +237,7 @@ class DropsCampaign:
return self.timed_drops.values()
@property
def active(self):
def active(self) -> bool:
return self.starts_at <= datetime.now(timezone.utc) < self.ends_at
@property
+2 -2
View File
@@ -8,7 +8,7 @@ from functools import partial
from collections import abc, OrderedDict
from datetime import datetime, timedelta, timezone
from contextlib import suppress, asynccontextmanager
from typing import Final, NoReturn, cast, TYPE_CHECKING
from typing import Any, Literal, Final, NoReturn, cast, TYPE_CHECKING
import aiohttp
from yarl import URL
@@ -108,7 +108,7 @@ class Twitch:
# this allows aiohttp to safely close the session
await asyncio.sleep(start_time + 0.5 - time())
def wait_until_login(self):
def wait_until_login(self) -> abc.Coroutine[Any, Any, Literal[True]]:
return self._is_logged_in.wait()
def change_state(self, state: State) -> None:
+2 -2
View File
@@ -261,7 +261,7 @@ class AwaitableValue(Generic[_T]):
return self._event.is_set()
def wait(self) -> abc.Coroutine[Any, Any, Literal[True]]:
return cast("abc.Coroutine[Any, Any, Literal[True]]", self._event.wait())
return self._event.wait()
def get_with_default(self, default: _D) -> _T | _D:
if self._event.is_set():
@@ -291,7 +291,7 @@ class Game:
def __repr__(self) -> str:
return f"Game({self.id}, {self.name})"
def __eq__(self, other: object):
def __eq__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return self.id == other.id
return NotImplemented
+2 -2
View File
@@ -5,7 +5,7 @@ import asyncio
import logging
from time import time
from contextlib import suppress
from typing import TYPE_CHECKING
from typing import Any, Literal, TYPE_CHECKING
import aiohttp
@@ -323,7 +323,7 @@ class WebsocketPool:
def running(self) -> bool:
return self._running.is_set()
def wait_until_connected(self):
def wait_until_connected(self) -> abc.Coroutine[Any, Any, Literal[True]]:
return self._running.wait()
async def start(self):