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