From f919850ad258adf3a13f5619bb712e09c61037d3 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sun, 31 Jul 2022 21:40:03 +0200 Subject: [PATCH] Typing update --- channel.py | 2 +- constants.py | 4 ++-- inventory.py | 2 +- twitch.py | 4 ++-- utils.py | 4 ++-- websocket.py | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/channel.py b/channel.py index f9f725b..6ab6d2f 100644 --- a/channel.py +++ b/channel.py @@ -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 diff --git a/constants.py b/constants.py index 79e022d..2f08901 100644 --- a/constants.py +++ b/constants.py @@ -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): diff --git a/inventory.py b/inventory.py index 385e88d..64249c5 100644 --- a/inventory.py +++ b/inventory.py @@ -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 diff --git a/twitch.py b/twitch.py index 7e32117..97128d8 100644 --- a/twitch.py +++ b/twitch.py @@ -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: diff --git a/utils.py b/utils.py index 37d5cbe..36aa3bf 100644 --- a/utils.py +++ b/utils.py @@ -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 diff --git a/websocket.py b/websocket.py index 7e73960..dd734e8 100644 --- a/websocket.py +++ b/websocket.py @@ -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):