Skip to content

Commit

Permalink
Typing fixes (home-assistant#12015)
Browse files Browse the repository at this point in the history
* .gitignore: Add .mypy_cache

* Typing fixes
  • Loading branch information
scop authored and balloob committed Jan 29, 2018
1 parent 78a3c01 commit 384f63d
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ desktop.ini
/home-assistant.pyproj
/home-assistant.sln
/.vs/*

# mypy
/.mypy_cache/*
2 changes: 1 addition & 1 deletion homeassistant/components/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def async_turn_off(self, **kwargs):
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()
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/binary_sensor/ihc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/cover/isy994.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/device_tracker/unifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fan/comfoconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -93,7 +93,7 @@ def turn_on(self, speed: str=None, **kwargs) -> None:
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)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hdmi_cec.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def _start_cec(event):
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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ihc/ihcdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/light/ihc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/light/tplink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/media_player/hdmi_cec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" % (
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/media_player/onkyo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"""
import logging

# pylint: disable=unused-import
from typing import List # noqa: F401

import voluptuous as vol

from homeassistant.components.media_player import (
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/media_player/webostv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
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 (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/pilight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/recorder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import threading
import time

from typing import Dict, Optional
from typing import Any, Dict, Optional # noqa: F401

import voluptuous as vol

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/sensor/comfoconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/sensor/daikin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/ihc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/switch/hdmi_cec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" % (
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/switch/ihc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/unit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def length(self: object, length: float, from_unit: str) -> float:
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."""
Expand Down

0 comments on commit 384f63d

Please sign in to comment.