From 9092a76dbf44103fd416d2f72bd55cc463950ef9 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Tue, 21 Mar 2023 13:26:03 +0100 Subject: [PATCH] Correct typing of pymodbus in modbus (#90039) --- homeassistant/components/modbus/modbus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index b53cfda104e..cb3501f3375 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -390,12 +390,12 @@ class ModbusHub: def _pymodbus_call( self, unit: int | None, address: int, value: int | list[int], use_call: str - ) -> ModbusResponse: + ) -> ModbusResponse | None: """Call sync. pymodbus.""" kwargs = {"slave": unit} if unit else {} entry = self._pb_call[use_call] try: - result = entry.func(address, value, **kwargs) + result: ModbusResponse = entry.func(address, value, **kwargs) except ModbusException as exception_error: self._log_error(str(exception_error)) return None