Fix typing runtime problems
This commit is contained in:
1 parent
08c6c20379
commit
a10c0bf389
4 files changed
+12
-10
No files matched your search
+6
-4
@@ -2,19 +2,21 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from copy import copy
|
||||
from collections import abc
|
||||
from enum import Enum, auto
|
||||
from datetime import timedelta
|
||||
from typing import Any, Literal
|
||||
from typing import Any, Dict, Literal, TYPE_CHECKING
|
||||
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from version import __version__
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections import abc # noqa
|
||||
|
||||
|
||||
# Typing
|
||||
JsonType: TypeAlias = "dict[str, Any]"
|
||||
TopicProcess = abc.Callable[[int, JsonType], Any]
|
||||
JsonType = Dict[str, Any]
|
||||
TopicProcess: TypeAlias = "abc.Callable[[int, JsonType], Any]"
|
||||
# Values
|
||||
MAX_WEBSOCKETS = 8
|
||||
WS_TOPICS_LIMIT = 50
|
||||
|
||||
+1
-1
@@ -4,12 +4,12 @@ from typing import TYPE_CHECKING
|
||||
from functools import cached_property
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from channel import Channel
|
||||
from constants import GQL_OPERATIONS
|
||||
from utils import timestamp, invalidate_cache, Game
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from twitch import Twitch
|
||||
from channel import Channel
|
||||
from collections import abc
|
||||
from constants import JsonType
|
||||
from gui import CampaignProgress
|
||||
|
||||
@@ -7,8 +7,8 @@ from yarl import URL
|
||||
from time import time
|
||||
from itertools import chain
|
||||
from functools import partial
|
||||
from typing import TYPE_CHECKING
|
||||
from collections import OrderedDict
|
||||
from typing import cast, TYPE_CHECKING
|
||||
from contextlib import suppress, asynccontextmanager
|
||||
|
||||
try:
|
||||
@@ -38,9 +38,9 @@ from constants import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Final
|
||||
from collections import abc
|
||||
from datetime import datetime
|
||||
from typing import Final, cast
|
||||
|
||||
from utils import Game
|
||||
from gui import LoginForm
|
||||
|
||||
@@ -8,7 +8,7 @@ from functools import wraps
|
||||
from contextlib import suppress
|
||||
from datetime import datetime, timezone
|
||||
from collections import abc, OrderedDict
|
||||
from typing import Any, Literal, Generic, TypeVar, cast, TYPE_CHECKING
|
||||
from typing import Any, Literal, MutableSet, Generic, TypeVar, cast, TYPE_CHECKING
|
||||
|
||||
from constants import JsonType
|
||||
|
||||
@@ -62,7 +62,7 @@ def invalidate_cache(instance, *attrnames):
|
||||
delattr(instance, name)
|
||||
|
||||
|
||||
class OrderedSet(abc.MutableSet[_T]):
|
||||
class OrderedSet(MutableSet[_T]):
|
||||
"""
|
||||
Implementation of a set that preserves insertion order,
|
||||
based on OrderedDict with values set to None.
|
||||
@@ -111,7 +111,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 cast("abc.Coroutine[Any, Any, Literal[True]]", self._event.wait())
|
||||
|
||||
def get_with_default(self, default: _D) -> _T | _D:
|
||||
if self._event.is_set():
|
||||
|
||||
Reference in new issue
Block a user