From 4ba6a30d510820e3b835a608e75d5c56c2371c8b Mon Sep 17 00:00:00 2001
From: Alex Ruddick <alex@ruddick.tech>
Date: Sat, 24 Feb 2024 18:49:54 -0600
Subject: [PATCH] Improve types for messages

---
 pymodbus/file_message.py | 3 ++-
 pymodbus/mei_message.py  | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pymodbus/file_message.py b/pymodbus/file_message.py
index f9a7622b93..f619ace54c 100644
--- a/pymodbus/file_message.py
+++ b/pymodbus/file_message.py
@@ -2,6 +2,7 @@
 
 Currently none of these messages are implemented
 """
+from __future__ import annotations
 
 __all__ = [
     "FileRecord",
@@ -147,7 +148,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 1291fbed8e..8d94d3fc79 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()):