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:
Ville SkyttäandFranck Nijhof authored and GitHub committed 2019-09-29 20:07:49 +03:00
1 parent 4f55235aa2
commit f259ff17d5
27 files changed
+184 -68

No files matched your search

+9 -4
View File
@@ -1,9 +1,10 @@
"""Support for the definition of zones."""
import logging
from typing import Set, cast
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.core import callback, State
from homeassistant.loader import bind_hass
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (
@@ -25,6 +26,9 @@ from .config_flow import configured_zones
from .const import CONF_PASSIVE, DOMAIN, HOME_ZONE, ATTR_PASSIVE, ATTR_RADIUS
from .zone import Zone
# mypy: allow-untyped-calls, allow-untyped-defs
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "Unnamed zone"
@@ -78,10 +82,11 @@ def async_active_zone(hass, latitude, longitude, radius=0):
)
within_zone = zone_dist - radius < zone.attributes[ATTR_RADIUS]
closer_zone = closest is None or zone_dist < min_dist
closer_zone = closest is None or zone_dist < min_dist # type: ignore
smaller_zone = (
zone_dist == min_dist
and zone.attributes[ATTR_RADIUS] < closest.attributes[ATTR_RADIUS]
and zone.attributes[ATTR_RADIUS]
< cast(State, closest).attributes[ATTR_RADIUS]
)
if within_zone and (closer_zone or smaller_zone):
@@ -94,7 +99,7 @@ def async_active_zone(hass, latitude, longitude, radius=0):
async def async_setup(hass, config):
"""Set up configured zones as well as home assistant zone if necessary."""
hass.data[DOMAIN] = {}
entities = set()
entities: Set[str] = set()
zone_entries = configured_zones(hass)
for _, entry in config_per_platform(config, DOMAIN):
if slugify(entry[CONF_NAME]) not in zone_entries: