Skip to content

Commit

Permalink
fix a couple types
Browse files Browse the repository at this point in the history
  • Loading branch information
marios8543 committed Nov 13, 2023
1 parent 70532c8 commit 8b0d175
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions backend/decky_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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]]
Expand Down
5 changes: 3 additions & 2 deletions backend/decky_loader/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self, context: PluginManager) -> None:
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()
Expand Down Expand Up @@ -182,7 +182,8 @@ async def remove_css_from_tab(self, tab: str, css_id: str):
style.parentNode.removeChild(style);
}})()
""", False)


assert result
if "exceptionDetails" in result["result"]:
raise result["result"]["exceptionDetails"]

Expand Down
8 changes: 4 additions & 4 deletions backend/decky_loader/wsrouter.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -133,7 +133,7 @@ async def handle(self, request: Request):
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 })

0 comments on commit 8b0d175

Please sign in to comment.