Typing fixes (#12015)

* .gitignore: Add .mypy_cache

* Typing fixes
This commit is contained in:
Ville Skyttä 2018-01-29 10:24:08 +02:00 committed by Paulus Schoutsen
parent 78a3c01f27
commit 384f63dd1d
23 changed files with 33 additions and 21 deletions

3
.gitignore vendored
View File

@ -98,3 +98,6 @@ desktop.ini
/home-assistant.pyproj
/home-assistant.sln
/.vs/*
# mypy
/.mypy_cache/*

View File

@ -277,7 +277,7 @@ class Alert(ToggleEntity):
yield from self.async_update_ha_state()
@asyncio.coroutine
def async_toggle(self):
def async_toggle(self, **kwargs):
"""Async toggle alert."""
if self._ack:
return self.async_turn_on()

View File

@ -69,7 +69,8 @@ class IHCBinarySensor(IHCDevice, BinarySensorDevice):
"""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
sensor_type: str, inverting: bool, product: Element=None):
sensor_type: str, inverting: bool,
product: Element=None) -> None:
"""Initialize the IHC binary sensor."""
super().__init__(ihc_controller, name, ihc_id, info, product)
self._state = None

View File

@ -42,7 +42,7 @@ def setup_platform(hass, config: ConfigType,
class ISYCoverDevice(ISYDevice, CoverDevice):
"""Representation of an ISY994 cover device."""
def __init__(self, node: object):
def __init__(self, node: object) -> None:
"""Initialize the ISY994 cover device."""
super().__init__(node)

View File

@ -75,7 +75,7 @@ def get_scanner(hass, config):
class UnifiScanner(DeviceScanner):
"""Provide device_tracker support from Unifi WAP client data."""
def __init__(self, controller, detection_time: timedelta):
def __init__(self, controller, detection_time: timedelta) -> None:
"""Initialize the scanner."""
self._detection_time = detection_time
self._controller = controller

View File

@ -37,7 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ComfoConnectFan(FanEntity):
"""Representation of the ComfoConnect fan platform."""
def __init__(self, hass, name, ccb: ComfoConnectBridge):
def __init__(self, hass, name, ccb: ComfoConnectBridge) -> None:
"""Initialize the ComfoConnect fan."""
from pycomfoconnect import SENSOR_FAN_SPEED_MODE
@ -93,7 +93,7 @@ class ComfoConnectFan(FanEntity):
speed = SPEED_LOW
self.set_speed(speed)
def turn_off(self) -> None:
def turn_off(self, **kwargs) -> None:
"""Turn off the fan (to away)."""
self.set_speed(SPEED_OFF)

View File

@ -320,7 +320,7 @@ def setup(hass: HomeAssistant, base_config):
class CecDevice(Entity):
"""Representation of a HDMI CEC device entity."""
def __init__(self, hass: HomeAssistant, device, logical):
def __init__(self, hass: HomeAssistant, device, logical) -> None:
"""Initialize the device."""
self._device = device
self.hass = hass

View File

@ -14,7 +14,7 @@ class IHCDevice(Entity):
"""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
product: Element=None):
product: Element=None) -> None:
"""Initialize IHC attributes."""
self.ihc_controller = ihc_controller
self._name = name

View File

@ -64,7 +64,7 @@ class IhcLight(IHCDevice, Light):
"""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
dimmable=False, product: Element=None):
dimmable=False, product: Element=None) -> None:
"""Initialize the light."""
super().__init__(ihc_controller, name, ihc_id, info, product)
self._brightness = 0

View File

@ -75,7 +75,7 @@ def hsv_to_rgb(hsv: Tuple[float, float, float]) -> Tuple[int, int, int]:
class TPLinkSmartBulb(Light):
"""Representation of a TPLink Smart Bulb."""
def __init__(self, smartbulb: 'SmartBulb', name):
def __init__(self, smartbulb: 'SmartBulb', name) -> None:
"""Initialize the bulb."""
self.smartbulb = smartbulb
self._name = name

View File

@ -34,7 +34,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class CecPlayerDevice(CecDevice, MediaPlayerDevice):
"""Representation of a HDMI device as a Media palyer."""
def __init__(self, hass: HomeAssistant, device, logical):
def __init__(self, hass: HomeAssistant, device, logical) -> None:
"""Initialize the HDMI device."""
CecDevice.__init__(self, hass, device, logical)
self.entity_id = "%s.%s_%s" % (

View File

@ -6,6 +6,9 @@ https://home-assistant.io/components/media_player.onkyo/
"""
import logging
# pylint: disable=unused-import
from typing import List # noqa: F401
import voluptuous as vol
from homeassistant.components.media_player import (

View File

@ -9,6 +9,9 @@ from datetime import timedelta
import logging
from urllib.parse import urlparse
# pylint: disable=unused-import
from typing import Dict # noqa: F401
import voluptuous as vol
from homeassistant.components.media_player import (

View File

@ -130,7 +130,7 @@ class CallRateDelayThrottle(object):
it should not block the mainloop.
"""
def __init__(self, hass, delay_seconds: float):
def __init__(self, hass, delay_seconds: float) -> None:
"""Initialize the delay handler."""
self._delay = timedelta(seconds=max(0.0, delay_seconds))
self._queue = []

View File

@ -16,7 +16,7 @@ import queue
import threading
import time
from typing import Dict, Optional
from typing import Any, Dict, Optional # noqa: F401
import voluptuous as vol

View File

@ -96,7 +96,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class ComfoConnectSensor(Entity):
"""Representation of a ComfoConnect sensor."""
def __init__(self, hass, name, ccb: ComfoConnectBridge, sensor_type):
def __init__(self, hass, name, ccb: ComfoConnectBridge,
sensor_type) -> None:
"""Initialize the ComfoConnect sensor."""
self._ccb = ccb
self._sensor_type = sensor_type

View File

@ -57,7 +57,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DaikinClimateSensor(Entity):
"""Representation of a Sensor."""
def __init__(self, api, monitored_state, units: UnitSystem, name=None):
def __init__(self, api, monitored_state, units: UnitSystem,
name=None) -> None:
"""Initialize the sensor."""
self._api = api
self._sensor = SENSOR_TYPES.get(monitored_state)

View File

@ -62,7 +62,7 @@ class IHCSensor(IHCDevice, Entity):
"""Implementation of the IHC sensor."""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
unit, product: Element=None):
unit, product: Element=None) -> None:
"""Initialize the IHC sensor."""
super().__init__(ihc_controller, name, ihc_id, info, product)
self._state = None

View File

@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class CecSwitchDevice(CecDevice, SwitchDevice):
"""Representation of a HDMI device as a Switch."""
def __init__(self, hass: HomeAssistant, device, logical):
def __init__(self, hass: HomeAssistant, device, logical) -> None:
"""Initialize the HDMI device."""
CecDevice.__init__(self, hass, device, logical)
self.entity_id = "%s.%s_%s" % (

View File

@ -53,7 +53,7 @@ class IHCSwitch(IHCDevice, SwitchDevice):
"""IHC Switch."""
def __init__(self, ihc_controller, name: str, ihc_id: int,
info: bool, product: Element=None):
info: bool, product: Element=None) -> None:
"""Initialize the IHC switch."""
super().__init__(ihc_controller, name, ihc_id, product)
self._state = False

View File

@ -19,7 +19,7 @@ import sys
from types import ModuleType
# pylint: disable=unused-import
from typing import Dict, Optional, Sequence, Set # NOQA
from typing import Dict, List, Optional, Sequence, Set # NOQA
from homeassistant.const import PLATFORM_FORMAT
from homeassistant.util import OrderedSet

View File

@ -3,7 +3,7 @@ import datetime as dt
import re
# pylint: disable=unused-import
from typing import Any, Union, Optional, Tuple # NOQA
from typing import Any, Dict, Union, Optional, Tuple # NOQA
import pytz

View File

@ -105,7 +105,7 @@ class UnitSystem(object):
raise TypeError('{} is not a numeric value.'.format(str(length)))
return distance_util.convert(length, from_unit,
self.length_unit) # type: float
self.length_unit)
def as_dict(self) -> dict:
"""Convert the unit system to a dictionary."""