Typing misc fixes (#27543)

* Make async_get_conditions return type hint more specific

* Exclude script/scaffold/templates/ from pre-commit mypy
This commit is contained in:
Ville Skyttä 2019-10-14 23:03:37 +03:00 committed by Paulus Schoutsen
parent 2f6c2fadd0
commit 759ad08930
7 changed files with 24 additions and 13 deletions

View file

@ -17,3 +17,4 @@ repos:
rev: v0.730 rev: v0.730
hooks: hooks:
- id: mypy - id: mypy
exclude: ^script/scaffold/templates/

View file

@ -1,5 +1,5 @@
"""Implemenet device conditions for binary sensor.""" """Implemenet device conditions for binary sensor."""
from typing import List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -193,9 +193,11 @@ CONDITION_SCHEMA = cv.DEVICE_CONDITION_BASE_SCHEMA.extend(
) )
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]: async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions.""" """List device conditions."""
conditions: List[dict] = [] conditions: List[Dict[str, str]] = []
entity_registry = await async_get_registry(hass) entity_registry = await async_get_registry(hass)
entries = [ entries = [
entry entry

View file

@ -205,7 +205,7 @@ async def async_get_actions(
async def async_get_conditions( async def async_get_conditions(
hass: HomeAssistant, device_id: str, domain: str hass: HomeAssistant, device_id: str, domain: str
) -> List[dict]: ) -> List[Dict[str, str]]:
"""List device conditions.""" """List device conditions."""
return await _async_get_automations(hass, device_id, ENTITY_CONDITIONS, domain) return await _async_get_automations(hass, device_id, ENTITY_CONDITIONS, domain)

View file

@ -1,5 +1,5 @@
"""Provides device conditions for lights.""" """Provides device conditions for lights."""
from typing import List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -24,7 +24,9 @@ def async_condition_from_config(
return toggle_entity.async_condition_from_config(config) return toggle_entity.async_condition_from_config(config)
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]: async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions.""" """List device conditions."""
return await toggle_entity.async_get_conditions(hass, device_id, DOMAIN) return await toggle_entity.async_get_conditions(hass, device_id, DOMAIN)

View file

@ -1,5 +1,5 @@
"""Provides device conditions for sensors.""" """Provides device conditions for sensors."""
from typing import List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -80,9 +80,11 @@ CONDITION_SCHEMA = vol.All(
) )
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]: async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions.""" """List device conditions."""
conditions: List[dict] = [] conditions: List[Dict[str, str]] = []
entity_registry = await async_get_registry(hass) entity_registry = await async_get_registry(hass)
entries = [ entries = [
entry entry

View file

@ -1,5 +1,5 @@
"""Provides device conditions for switches.""" """Provides device conditions for switches."""
from typing import List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -24,7 +24,9 @@ def async_condition_from_config(
return toggle_entity.async_condition_from_config(config) return toggle_entity.async_condition_from_config(config)
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]: async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions.""" """List device conditions."""
return await toggle_entity.async_get_conditions(hass, device_id, DOMAIN) return await toggle_entity.async_get_conditions(hass, device_id, DOMAIN)

View file

@ -1,5 +1,5 @@
"""Provides device automations for NEW_NAME.""" """Provides device automations for NEW_NAME."""
from typing import List from typing import Dict, List
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ( from homeassistant.const import (
@ -29,7 +29,9 @@ CONDITION_SCHEMA = DEVICE_CONDITION_BASE_SCHEMA.extend(
) )
async def async_get_conditions(hass: HomeAssistant, device_id: str) -> List[dict]: async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions for NEW_NAME devices.""" """List device conditions for NEW_NAME devices."""
registry = await entity_registry.async_get_registry(hass) registry = await entity_registry.async_get_registry(hass)
conditions = [] conditions = []