From e56c64db072eed3c0a8e796fe16c8ff6ee80e1d0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:06:44 +0100 Subject: [PATCH] Remove screenlogic from mypy ignore list (#64512) * Adjust screenlogic * Adjust mypy_config * Adjust coordinator cast * Move cast higher up Co-authored-by: epenet --- homeassistant/components/screenlogic/number.py | 9 ++++++--- homeassistant/components/screenlogic/services.py | 3 ++- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/screenlogic/number.py b/homeassistant/components/screenlogic/number.py index 253b5c9641e..de634feaef9 100644 --- a/homeassistant/components/screenlogic/number.py +++ b/homeassistant/components/screenlogic/number.py @@ -1,5 +1,6 @@ """Support for a ScreenLogic number entity.""" import logging +from typing import cast from screenlogicpy.const import BODY_TYPE, DATA as SL_DATA, EQUIPMENT, SCG @@ -8,7 +9,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from . import ScreenlogicEntity +from . import ScreenlogicDataUpdateCoordinator, ScreenlogicEntity from .const import DOMAIN _LOGGER = logging.getLogger(__name__) @@ -57,14 +58,16 @@ class ScreenLogicNumber(ScreenlogicEntity, NumberEntity): async def async_set_value(self, value: float) -> None: """Update the current value.""" + coordinator = cast(ScreenlogicDataUpdateCoordinator, self.coordinator) + # Need to set both levels at the same time, so we gather # both existing level values and override the one that changed. levels = {} for level in SUPPORTED_SCG_NUMBERS: - levels[level] = self.coordinator.data[SL_DATA.KEY_SCG][level]["value"] + levels[level] = coordinator.data[SL_DATA.KEY_SCG][level]["value"] levels[self._data_key] = int(value) - if await self.coordinator.gateway.async_set_scg_config( + if await coordinator.gateway.async_set_scg_config( levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.POOL]], levels[SUPPORTED_SCG_NUMBERS[BODY_TYPE.SPA]], ): diff --git a/homeassistant/components/screenlogic/services.py b/homeassistant/components/screenlogic/services.py index 62027a41949..09f76c0e09e 100644 --- a/homeassistant/components/screenlogic/services.py +++ b/homeassistant/components/screenlogic/services.py @@ -37,7 +37,8 @@ def async_load_screenlogic_services(hass: HomeAssistant): return [ entry_id for entry_id in await async_extract_config_entry_ids(hass, service_call) - if hass.config_entries.async_get_entry(entry_id).domain == DOMAIN + if (entry := hass.config_entries.async_get_entry(entry_id)) + and entry.domain == DOMAIN ] async def async_set_color_mode(service_call: ServiceCall) -> None: diff --git a/mypy.ini b/mypy.ini index 5e92d2bbe15..0d19d1be02a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2182,9 +2182,6 @@ ignore_errors = true [mypy-homeassistant.components.ruckus_unleashed.*] ignore_errors = true -[mypy-homeassistant.components.screenlogic.*] -ignore_errors = true - [mypy-homeassistant.components.search.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index c4ed4722220..039fc7677ba 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -69,7 +69,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.profiler.*", "homeassistant.components.ring.*", "homeassistant.components.ruckus_unleashed.*", - "homeassistant.components.screenlogic.*", "homeassistant.components.search.*", "homeassistant.components.sense.*", "homeassistant.components.sharkiq.*",