Fix modbus typing (#49938)

Add changes needed to please mypy and follow the coding rules
of the project.
This commit is contained in:
jan iversen
2021-05-03 22:45:21 +02:00
committed by GitHub
parent c69eeddc7b
commit f0ec9c38b0
5 changed files with 9 additions and 18 deletions

View File

@@ -58,7 +58,6 @@ from .const import (
DEFAULT_STRUCT_FORMAT,
MODBUS_DOMAIN,
)
from .modbus import ModbusHub
_LOGGER = logging.getLogger(__name__)
@@ -120,7 +119,6 @@ async def async_setup_platform(
entry[CONF_INPUT_TYPE] = entry[CONF_REGISTER_TYPE]
del entry[CONF_REGISTER]
del entry[CONF_REGISTER_TYPE]
config = None
for entry in discovery_info[CONF_SENSORS]:
if entry[CONF_DATA_TYPE] == DATA_TYPE_STRING:
@@ -175,9 +173,9 @@ async def async_setup_platform(
continue
if CONF_HUB in entry:
# from old config!
hub: ModbusHub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
hub = hass.data[MODBUS_DOMAIN][entry[CONF_HUB]]
else:
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
hub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
if CONF_SCAN_INTERVAL not in entry:
entry[CONF_SCAN_INTERVAL] = DEFAULT_SCAN_INTERVAL
sensors.append(