fix a couple types

This commit is contained in:
marios8543
2023-11-14 00:34:48 +02:00
parent 70532c8d0b
commit 8b0d1753ef
3 changed files with 8 additions and 6 deletions
+1
View File
@@ -18,6 +18,7 @@ if TYPE_CHECKING:
from .injector import get_gamepadui_tab
from .plugin.plugin import PluginWrapper
from .wsrouter import WSRouter
Plugins = dict[str, PluginWrapper]
ReloadQueue = Queue[Tuple[str, str, bool | None] | Tuple[str, str]]
+3 -2
View File
@@ -82,7 +82,7 @@ class Utilities:
context.ws.add_route("utilities/get_tab_id", self.get_tab_id)
context.ws.add_route("utilities/get_user_info", self.get_user_info)
async def _handle_server_method_call(self, request):
async def _handle_server_method_call(self, request: web.Request):
method_name = request.match_info["method_name"]
try:
args = await request.json()
@@ -182,7 +182,8 @@ class Utilities:
style.parentNode.removeChild(style);
}})()
""", False)
assert result
if "exceptionDetails" in result["result"]:
raise result["result"]["exceptionDetails"]
+4 -4
View File
@@ -1,13 +1,13 @@
from logging import getLogger
from asyncio import AbstractEventLoop, Future, create_task
from asyncio import AbstractEventLoop, create_task
from aiohttp import WSMsgType, WSMessage
from aiohttp.web import Application, WebSocketResponse, Request, Response, get
from enum import IntEnum
from typing import Callable, Dict, Any, cast, TypeVar, Type
from typing import Callable, Coroutine, Dict, Any, cast, TypeVar, Type
from dataclasses import dataclass
from traceback import format_exc
@@ -38,7 +38,7 @@ class Message:
DataType = TypeVar("DataType")
Route = Callable[..., Future[Any]]
Route = Callable[..., Coroutine[Any, Any, Any]]
class WSRouter:
def __init__(self, loop: AbstractEventLoop, server_instance: Application) -> None:
@@ -133,7 +133,7 @@ class WSRouter:
return ws
# DataType defaults to None so that if a plugin opts in to strict pyright checking and attempts to pass data witbout specifying the type (or any), the type check fails
async def emit(self, event: str, data: DataType | None = None, data_type: Type[DataType] = None):
async def emit(self, event: str, data: DataType | None = None, data_type: Type[DataType]|None = None):
self.logger.debug('Firing frontend event %s with args %s', data)
await self.write({ "type": MessageType.EVENT.value, "event": event, "data": data })