Add setup type hints to homeassistant (#63439)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-05 17:35:17 +01:00 committed by GitHub
parent 4c48705fe8
commit ef309182fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -34,7 +34,9 @@ from homeassistant.helpers import (
config_validation as cv,
entity_platform,
)
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.state import async_reproduce_state
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.loader import async_get_integration
@ -162,7 +164,12 @@ def entities_in_scene(hass: HomeAssistant, entity_id: str) -> list[str]:
return list(entity.scene_config.states)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up Home Assistant scene entries."""
_process_scenes_config(hass, async_add_entities, config)
@ -252,7 +259,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
scene_config = SceneConfig(None, call.data[CONF_SCENE_ID], None, entities)
entity_id = f"{SCENE_DOMAIN}.{scene_config.name}"
if (old := platform.entities.get(entity_id)) is not None:
if not old.from_service:
if not isinstance(old, HomeAssistantScene) or not old.from_service:
_LOGGER.warning("The scene %s already exists", entity_id)
return
await platform.async_remove_entity(entity_id)