From 9a533512d41f42cb8bf04b205fd00e156b7724b6 Mon Sep 17 00:00:00 2001 From: Alex <52292902+alexrudd2@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:59:19 -0600 Subject: [PATCH] Specify more types in base framer (#2005) Co-authored-by: jan iversen --- pymodbus/framer/base.py | 6 +++--- pymodbus/framer/rtu_framer.py | 2 +- pymodbus/framer/socket_framer.py | 2 +- pymodbus/framer/tls_framer.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pymodbus/framer/base.py b/pymodbus/framer/base.py index 1c9b91f0a..27ac9724c 100644 --- a/pymodbus/framer/base.py +++ b/pymodbus/framer/base.py @@ -27,7 +27,7 @@ class ModbusFramer: def __init__( self, decoder: ClientDecoder | ServerDecoder, - client=None, + client, ) -> None: """Initialize a new instance of the framer. @@ -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 diff --git a/pymodbus/framer/rtu_framer.py b/pymodbus/framer/rtu_framer.py index 55150ff67..491d8d0e6 100644 --- a/pymodbus/framer/rtu_framer.py +++ b/pymodbus/framer/rtu_framer.py @@ -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? diff --git a/pymodbus/framer/socket_framer.py b/pymodbus/framer/socket_framer.py index 4acf23356..78f28bd3e 100644 --- a/pymodbus/framer/socket_framer.py +++ b/pymodbus/framer/socket_framer.py @@ -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: diff --git a/pymodbus/framer/tls_framer.py b/pymodbus/framer/tls_framer.py index 5114c028c..6b9a1d4c4 100644 --- a/pymodbus/framer/tls_framer.py +++ b/pymodbus/framer/tls_framer.py @@ -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?