From f6037b966253d54392ee08b0bfce3f4720c9cdc0 Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Sat, 24 Feb 2024 18:49:54 -0600 Subject: [PATCH] Improve types for messages --- pymodbus/file_message.py | 4 +++- pymodbus/mei_message.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pymodbus/file_message.py b/pymodbus/file_message.py index f9a7622b9..82c0ad7e4 100644 --- a/pymodbus/file_message.py +++ b/pymodbus/file_message.py @@ -2,6 +2,8 @@ Currently none of these messages are implemented """ +from __future__ import annotations + __all__ = [ "FileRecord", @@ -147,7 +149,7 @@ def execute(self, _context): # TODO do some new context operation here # pylint: disable=fixme # if file number, record number, or address + length # is too big, return an error. - files = [] + files: list[FileRecord] = [] return ReadFileRecordResponse(files) diff --git a/pymodbus/mei_message.py b/pymodbus/mei_message.py index 1291fbed8..8d94d3fc7 100644 --- a/pymodbus/mei_message.py +++ b/pymodbus/mei_message.py @@ -147,7 +147,7 @@ def __init__(self, read_code=None, information=None, **kwargs): self.conformity = 0x83 # I support everything right now self.next_object_id = 0x00 self.more_follows = MoreData.NOTHING - self.space_left = None + self.space_left = 253 - 6 def _encode_object(self, object_id, data): """Encode object.""" @@ -170,7 +170,6 @@ def encode(self): packet = struct.pack( ">BBB", self.sub_function_code, self.read_code, self.conformity ) - self.space_left = 253 - 6 objects = b"" try: for object_id, data in iter(self.information.items()):