Skip to content

Commit

Permalink
update typing for WebSocketApp
Browse files Browse the repository at this point in the history
  • Loading branch information
vchrisb committed Dec 4, 2023
1 parent 24e6542 commit 194a0ab
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions e3dc/_e3dc_rscp_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Any, Callable, Tuple

import tzlocal
from websocket import ABNF, WebSocketApp # pyright: ignore [reportMissingTypeStubs]
from websocket import ABNF, WebSocketApp # pyright: ignore [reportPrivateImportUsage]

from ._rscpLib import (
rscpDecode,
Expand Down Expand Up @@ -120,11 +120,9 @@ def __init__(
self.serialNumberWithPrefix = serialNumberWithPrefix.encode("utf-8")
self.ws = WebSocketApp(
REMOTE_ADDRESS,
on_message=lambda _, msg: self.on_message( # pyright: ignore [reportUnknownLambdaType]
msg # pyright: ignore [reportUnknownArgumentType]
),
on_close=lambda _: self.reset(), # pyright: ignore [reportUnknownLambdaType]
on_error=lambda _: self.reset(), # pyright: ignore [reportUnknownLambdaType]
on_message=lambda _, msg: self.on_message(msg),
on_close=lambda _ws, _, __: self.reset(),
on_error=lambda _ws, _: self.reset(),
)
self.reset()

Expand Down Expand Up @@ -163,9 +161,7 @@ def buildVirtualConn(self):
)

# print("--------------------- Sending virtual conn")
self.ws.send(
virtualConn, ABNF.OPCODE_BINARY # pyright: ignore [reportGeneralTypeIssues]
)
self.ws.send(virtualConn, ABNF.OPCODE_BINARY)

def respondToINFORequest(
self, decoded: Tuple[str | int | RscpTag, str | int | RscpType, Any]
Expand Down Expand Up @@ -255,9 +251,7 @@ def registerConnectionHandler(
],
)
)
self.ws.send(
reply, ABNF.OPCODE_BINARY # pyright: ignore [reportGeneralTypeIssues]
)
self.ws.send(reply, ABNF.OPCODE_BINARY)

def on_message(self, message: bytes):
"""Method to handle a received message."""
Expand All @@ -278,7 +272,7 @@ def on_message(self, message: bytes):
rscpEncode(RscpTag.SERVER_PING, RscpType.NoneType, None)
)
self.ws.send(
pingFrame, # pyright: ignore [reportGeneralTypeIssues]
pingFrame,
ABNF.OPCODE_BINARY,
)
return
Expand Down Expand Up @@ -328,9 +322,7 @@ def on_message(self, message: bytes):
)

self.ws.send(
rscpFrame(
responseContainer
), # pyright: ignore [reportGeneralTypeIssues]
rscpFrame(responseContainer),
ABNF.OPCODE_BINARY,
)

Expand Down Expand Up @@ -406,9 +398,7 @@ def _sendRequest_internal(
)
)

self.ws.send(
outerFrame, ABNF.OPCODE_BINARY # pyright: ignore [reportGeneralTypeIssues]
)
self.ws.send(outerFrame, ABNF.OPCODE_BINARY)

def connect(self):
"""Connect to E3DC system."""
Expand Down

0 comments on commit 194a0ab

Please sign in to comment.