Skip to content

Commit 23760b7

Browse files
authored
Improve simulator types (#2076)
1 parent cba37e2 commit 23760b7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pymodbus/server/simulator/http_server.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ def __init__(
180180
)
181181
self.web_app.on_startup.append(self.start_modbus_server)
182182
self.web_app.on_shutdown.append(self.stop_modbus_server)
183-
self.generator_html = {
183+
self.generator_html: dict[str, list] = {
184184
"log": ["", self.build_html_log],
185185
"registers": ["", self.build_html_registers],
186186
"calls": ["", self.build_html_calls],
187187
"server": ["", self.build_html_server],
188188
}
189-
self.generator_json = {
189+
self.generator_json: dict[str, list] = {
190190
"log_json": [None, self.build_json_log],
191191
"registers_json": [None, self.build_json_registers],
192192
"calls_json": [None, self.build_json_calls],
@@ -344,7 +344,7 @@ def build_html_registers(self, params, html):
344344
)
345345
return new_html
346346

347-
def build_html_calls(self, params, html):
347+
def build_html_calls(self, params: dict, html: str) -> str:
348348
"""Build html calls page."""
349349
result_txt, foot = self.helper_build_html_submit(params)
350350
if not foot:
@@ -380,10 +380,10 @@ def build_html_calls(self, params, html):
380380
for function in self.request_lookup.values():
381381
selected = (
382382
"selected"
383-
if function.function_code == self.call_monitor.function
383+
if function.function_code == self.call_monitor.function #type: ignore[attr-defined]
384384
else ""
385385
)
386-
function_codes += f"<option value={function.function_code} {selected}>{function.function_code_name}</option>"
386+
function_codes += f"<option value={function.function_code} {selected}>{function.function_code_name}</option>" #type: ignore[attr-defined]
387387
simulation_action = (
388388
"ACTIVE" if self.call_response.active != RESPONSE_INACTIVE else ""
389389
)
@@ -394,7 +394,7 @@ def build_html_calls(self, params, html):
394394
call_rows = ""
395395
for entry in reversed(self.call_list):
396396
# req_obj = self.request_lookup[entry[1]]
397-
call_rows += f"<tr><td>{entry.call} - {entry.fc}</td><td>{entry.address}</td><td>{entry.count}</td><td>{entry.data}</td></tr>"
397+
call_rows += f"<tr><td>{entry.call} - {entry.fc}</td><td>{entry.address}</td><td>{entry.count}</td><td>{entry.data.decode()}</td></tr>"
398398
# line += req_obj.funcion_code_name
399399
new_html = (
400400
html.replace("<!--SIMULATION_ACTIVE-->", simulation_action)

0 commit comments

Comments
 (0)