Type hint additions (#26831)
* Type hint additions * Remove optional from sidebar_icon comment Co-Authored-By: Franck Nijhof <frenck@frenck.nl> * Remove optional from sidebar_title comment Co-Authored-By: Franck Nijhof <frenck@frenck.nl> * Fix issues after rebase and mypy 0.730
This commit is contained in:
parent
4f55235aa2
commit
f259ff17d5
27 changed files with 184 additions and 68 deletions
|
@ -3,7 +3,7 @@ import asyncio
|
|||
from collections import Counter
|
||||
import itertools
|
||||
import logging
|
||||
from typing import Any, Callable, Iterator, List, Optional, Tuple
|
||||
from typing import Any, Callable, Iterator, List, Optional, Tuple, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -43,6 +43,9 @@ from homeassistant.components.light import (
|
|||
SUPPORT_WHITE_VALUE,
|
||||
)
|
||||
|
||||
|
||||
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_NAME = "Light Group"
|
||||
|
@ -69,7 +72,9 @@ async def async_setup_platform(
|
|||
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
|
||||
) -> None:
|
||||
"""Initialize light.group platform."""
|
||||
async_add_entities([LightGroup(config.get(CONF_NAME), config[CONF_ENTITIES])])
|
||||
async_add_entities(
|
||||
[LightGroup(cast(str, config.get(CONF_NAME)), config[CONF_ENTITIES])]
|
||||
)
|
||||
|
||||
|
||||
class LightGroup(light.Light):
|
||||
|
@ -263,7 +268,7 @@ class LightGroup(light.Light):
|
|||
async def async_update(self):
|
||||
"""Query all members and determine the light group state."""
|
||||
all_states = [self.hass.states.get(x) for x in self._entity_ids]
|
||||
states = list(filter(None, all_states))
|
||||
states: List[State] = list(filter(None, all_states))
|
||||
on_states = [state for state in states if state.state == STATE_ON]
|
||||
|
||||
self._is_on = len(on_states) > 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue