Skip to content

Commit

Permalink
Specify more types in base framer (#2005)
Browse files Browse the repository at this point in the history

Co-authored-by: jan iversen <[email protected]>
  • Loading branch information
alexrudd2 and janiversen authored Feb 11, 2024
1 parent 3d79d5f commit 9a53351
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pymodbus/framer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ModbusFramer:
def __init__(
self,
decoder: ClientDecoder | ServerDecoder,
client=None,
client,
) -> None:
"""Initialize a new instance of the framer.
Expand Down Expand Up @@ -140,10 +140,10 @@ def processIncomingPacket(self, data, callback, slave, **kwargs):

def frameProcessIncomingPacket(
self, _single, _callback, _slave, _tid=None, **kwargs
):
) -> None:
"""Process new packet pattern."""

def buildPacket(self, message):
def buildPacket(self, message) -> bytes: # type:ignore[empty-body]
"""Create a ready to send modbus packet.
:param message: The populated request/response to send
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/framer/rtu_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def _process(self, callback, error=False):
if (result := self.decoder.decode(data)) is None:
raise ModbusIOException("Unable to decode request")
if error and result.function_code < 0x80:
raise InvalidMessageReceivedException(result)
raise InvalidMessageReceivedException(str(result))
self.populateResult(result)
self.advanceFrame()
callback(result) # defer or push to a thread?
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/framer/socket_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _process(self, callback, tid, error=False):
self.resetFrame()
raise ModbusIOException("Unable to decode request")
if error and result.function_code < 0x80:
raise InvalidMessageReceivedException(result)
raise InvalidMessageReceivedException(str(result))
self.populateResult(result)
self.advanceFrame()
if tid and tid != result.transaction_id:
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/framer/tls_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _process(self, callback, error=False):
if (result := self.decoder.decode(data)) is None:
raise ModbusIOException("Unable to decode request")
if error and result.function_code < 0x80:
raise InvalidMessageReceivedException(result)
raise InvalidMessageReceivedException(str(result))
self.populateResult(result)
self.advanceFrame()
callback(result) # defer or push to a thread?
Expand Down

0 comments on commit 9a53351

Please sign in to comment.