Skip to content

Commit

Permalink
Remove self type hints (#15732)
Browse files Browse the repository at this point in the history
* Remove self type hints

* Lint
  • Loading branch information
awarecan authored and balloob committed Jul 30, 2018
1 parent 744c277 commit 1e5596b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 58 deletions.
8 changes: 4 additions & 4 deletions homeassistant/components/climate/honeywell.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def set_temperature(self, **kwargs):
self.client.set_temperature(self._name, temperature)

@property
def current_operation(self: ClimateDevice) -> str:
def current_operation(self) -> str:
"""Get the current operation of the system."""
return getattr(self.client, ATTR_SYSTEM_MODE, None)

Expand All @@ -174,7 +174,7 @@ def is_away_mode_on(self):
"""Return true if away mode is on."""
return self._away

def set_operation_mode(self: ClimateDevice, operation_mode: str) -> None:
def set_operation_mode(self, operation_mode: str) -> None:
"""Set the HVAC mode for the thermostat."""
if hasattr(self.client, ATTR_SYSTEM_MODE):
self.client.system_mode = operation_mode
Expand Down Expand Up @@ -280,7 +280,7 @@ def target_temperature(self):
return self._device.setpoint_heat

@property
def current_operation(self: ClimateDevice) -> str:
def current_operation(self) -> str:
"""Return current operation ie. heat, cool, idle."""
oper = getattr(self._device, ATTR_CURRENT_OPERATION, None)
if oper == "off":
Expand Down Expand Up @@ -373,7 +373,7 @@ def turn_away_mode_off(self):
except somecomfort.SomeComfortError:
_LOGGER.error('Can not stop hold mode')

def set_operation_mode(self: ClimateDevice, operation_mode: str) -> None:
def set_operation_mode(self, operation_mode: str) -> None:
"""Set the system mode (Cool, Heat, etc)."""
if hasattr(self._device, ATTR_SYSTEM_MODE):
self._device.system_mode = operation_mode
Expand Down
22 changes: 11 additions & 11 deletions homeassistant/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ def async_handle_fan_service(service):
class FanEntity(ToggleEntity):
"""Representation of a fan."""

def set_speed(self: ToggleEntity, speed: str) -> None:
def set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
raise NotImplementedError()

def async_set_speed(self: ToggleEntity, speed: str):
def async_set_speed(self, speed: str):
"""Set the speed of the fan.
This method must be run in the event loop and returns a coroutine.
Expand All @@ -248,24 +248,24 @@ def async_set_speed(self: ToggleEntity, speed: str):
return self.async_turn_off()
return self.hass.async_add_job(self.set_speed, speed)

def set_direction(self: ToggleEntity, direction: str) -> None:
def set_direction(self, direction: str) -> None:
"""Set the direction of the fan."""
raise NotImplementedError()

def async_set_direction(self: ToggleEntity, direction: str):
def async_set_direction(self, direction: str):
"""Set the direction of the fan.
This method must be run in the event loop and returns a coroutine.
"""
return self.hass.async_add_job(self.set_direction, direction)

# pylint: disable=arguments-differ
def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
raise NotImplementedError()

# pylint: disable=arguments-differ
def async_turn_on(self: ToggleEntity, speed: str = None, **kwargs):
def async_turn_on(self, speed: str = None, **kwargs):
"""Turn on the fan.
This method must be run in the event loop and returns a coroutine.
Expand All @@ -275,11 +275,11 @@ def async_turn_on(self: ToggleEntity, speed: str = None, **kwargs):
return self.hass.async_add_job(
ft.partial(self.turn_on, speed, **kwargs))

def oscillate(self: ToggleEntity, oscillating: bool) -> None:
def oscillate(self, oscillating: bool) -> None:
"""Oscillate the fan."""
pass

def async_oscillate(self: ToggleEntity, oscillating: bool):
def async_oscillate(self, oscillating: bool):
"""Oscillate the fan.
This method must be run in the event loop and returns a coroutine.
Expand All @@ -297,7 +297,7 @@ def speed(self) -> str:
return None

@property
def speed_list(self: ToggleEntity) -> list:
def speed_list(self) -> list:
"""Get the list of available speeds."""
return []

Expand All @@ -307,7 +307,7 @@ def current_direction(self) -> str:
return None

@property
def state_attributes(self: ToggleEntity) -> dict:
def state_attributes(self) -> dict:
"""Return optional state attributes."""
data = {} # type: dict

Expand All @@ -322,6 +322,6 @@ def state_attributes(self: ToggleEntity) -> dict:
return data

@property
def supported_features(self: ToggleEntity) -> int:
def supported_features(self) -> int:
"""Flag supported features."""
return 0
19 changes: 9 additions & 10 deletions homeassistant/components/fan/dyson.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.dyson import DYSON_DEVICES
from homeassistant.components.fan import (
DOMAIN, SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity)
from homeassistant.const import CONF_ENTITY_ID
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import ToggleEntity

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -100,7 +99,7 @@ def name(self):
"""Return the display name of this fan."""
return self._device.name

def set_speed(self: ToggleEntity, speed: str) -> None:
def set_speed(self, speed: str) -> None:
"""Set the speed of the fan. Never called ??."""
from libpurecoollink.const import FanSpeed, FanMode

Expand All @@ -113,7 +112,7 @@ def set_speed(self: ToggleEntity, speed: str) -> None:
self._device.set_configuration(
fan_mode=FanMode.FAN, fan_speed=fan_speed)

def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
from libpurecoollink.const import FanSpeed, FanMode

Expand All @@ -129,14 +128,14 @@ def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
# Speed not set, just turn on
self._device.set_configuration(fan_mode=FanMode.FAN)

def turn_off(self: ToggleEntity, **kwargs) -> None:
def turn_off(self, **kwargs) -> None:
"""Turn off the fan."""
from libpurecoollink.const import FanMode

_LOGGER.debug("Turn off fan %s", self.name)
self._device.set_configuration(fan_mode=FanMode.OFF)

def oscillate(self: ToggleEntity, oscillating: bool) -> None:
def oscillate(self, oscillating: bool) -> None:
"""Turn on/off oscillating."""
from libpurecoollink.const import Oscillation

Expand Down Expand Up @@ -183,7 +182,7 @@ def is_night_mode(self):
"""Return Night mode."""
return self._device.state.night_mode == "ON"

def night_mode(self: ToggleEntity, night_mode: bool) -> None:
def night_mode(self, night_mode: bool) -> None:
"""Turn fan in night mode."""
from libpurecoollink.const import NightMode

Expand All @@ -198,7 +197,7 @@ def is_auto_mode(self):
"""Return auto mode."""
return self._device.state.fan_mode == "AUTO"

def auto_mode(self: ToggleEntity, auto_mode: bool) -> None:
def auto_mode(self, auto_mode: bool) -> None:
"""Turn fan in auto mode."""
from libpurecoollink.const import FanMode

Expand All @@ -209,7 +208,7 @@ def auto_mode(self: ToggleEntity, auto_mode: bool) -> None:
self._device.set_configuration(fan_mode=FanMode.FAN)

@property
def speed_list(self: ToggleEntity) -> list:
def speed_list(self) -> list:
"""Get the list of available speeds."""
from libpurecoollink.const import FanSpeed

Expand All @@ -230,6 +229,6 @@ def speed_list(self: ToggleEntity) -> list:
return supported_speeds

@property
def supported_features(self: ToggleEntity) -> int:
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_OSCILLATE | SUPPORT_SET_SPEED
11 changes: 5 additions & 6 deletions homeassistant/components/fan/insteon_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import logging
from datetime import timedelta

from homeassistant import util
from homeassistant.components.fan import (
ATTR_SPEED, SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH,
SUPPORT_SET_SPEED, FanEntity)
from homeassistant.helpers.entity import ToggleEntity
from homeassistant import util

_CONFIGURING = {}
_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -68,7 +67,7 @@ def speed(self) -> str:
return self._speed

@property
def speed_list(self: ToggleEntity) -> list:
def speed_list(self) -> list:
"""Get the list of available speeds."""
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]

Expand All @@ -91,18 +90,18 @@ def supported_features(self):
"""Flag supported features."""
return SUPPORT_INSTEON_LOCAL

def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn device on."""
if speed is None:
speed = kwargs.get(ATTR_SPEED, SPEED_MEDIUM)

self.set_speed(speed)

def turn_off(self: ToggleEntity, **kwargs) -> None:
def turn_off(self, **kwargs) -> None:
"""Turn device off."""
self.node.off()

def set_speed(self: ToggleEntity, speed: str) -> None:
def set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
if self.node.on(speed):
self._speed = speed
20 changes: 8 additions & 12 deletions homeassistant/components/fan/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@

import voluptuous as vol

from homeassistant.core import callback
from homeassistant.const import (
CONF_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, CONF_ENTITY_ID,
STATE_ON, STATE_OFF, MATCH_ALL, EVENT_HOMEASSISTANT_START,
STATE_UNKNOWN)

from homeassistant.exceptions import TemplateError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.components.fan import (
SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH, SUPPORT_SET_SPEED, SUPPORT_OSCILLATE,
FanEntity, ATTR_SPEED, ATTR_OSCILLATING, ENTITY_ID_FORMAT,
SUPPORT_DIRECTION, DIRECTION_FORWARD, DIRECTION_REVERSE, ATTR_DIRECTION)

from homeassistant.const import (
CONF_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, CONF_ENTITY_ID,
STATE_ON, STATE_OFF, MATCH_ALL, EVENT_HOMEASSISTANT_START,
STATE_UNKNOWN)
from homeassistant.core import callback
from homeassistant.exceptions import TemplateError
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.script import Script

Expand Down Expand Up @@ -65,7 +61,7 @@
vol.Optional(CONF_ENTITY_ID): cv.entity_ids
})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
vol.Required(CONF_FANS): vol.Schema({cv.slug: FAN_SCHEMA}),
})

Expand Down Expand Up @@ -196,7 +192,7 @@ def supported_features(self) -> int:
return self._supported_features

@property
def speed_list(self: ToggleEntity) -> list:
def speed_list(self) -> list:
"""Get the list of available speeds."""
return self._speed_list

Expand Down
13 changes: 6 additions & 7 deletions homeassistant/components/fan/wink.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM, STATE_UNKNOWN, SUPPORT_DIRECTION,
SUPPORT_SET_SPEED, FanEntity)
from homeassistant.components.wink import DOMAIN, WinkDevice
from homeassistant.helpers.entity import ToggleEntity

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -39,19 +38,19 @@ def async_added_to_hass(self):
"""Call when entity is added to hass."""
self.hass.data[DOMAIN]['entities']['fan'].append(self)

def set_direction(self: ToggleEntity, direction: str) -> None:
def set_direction(self, direction: str) -> None:
"""Set the direction of the fan."""
self.wink.set_fan_direction(direction)

def set_speed(self: ToggleEntity, speed: str) -> None:
def set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
self.wink.set_state(True, speed)

def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
self.wink.set_state(True, speed)

def turn_off(self: ToggleEntity, **kwargs) -> None:
def turn_off(self, **kwargs) -> None:
"""Turn off the fan."""
self.wink.set_state(False)

Expand Down Expand Up @@ -82,7 +81,7 @@ def current_direction(self):
return self.wink.current_fan_direction()

@property
def speed_list(self: ToggleEntity) -> list:
def speed_list(self) -> list:
"""Get the list of available speeds."""
wink_supported_speeds = self.wink.fan_speeds()
supported_speeds = []
Expand All @@ -99,6 +98,6 @@ def speed_list(self: ToggleEntity) -> list:
return supported_speeds

@property
def supported_features(self: ToggleEntity) -> int:
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORTED_FEATURES
2 changes: 1 addition & 1 deletion homeassistant/components/fan/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def async_turn_off(self, **kwargs) -> None:
yield from self.async_set_speed(SPEED_OFF)

@asyncio.coroutine
def async_set_speed(self: FanEntity, speed: str) -> None:
def async_set_speed(self, speed: str) -> None:
"""Set the speed of the fan."""
yield from self._endpoint.fan.write_attributes({
'fan_mode': SPEED_TO_VALUE[speed]})
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,25 @@ class OrderedEnum(enum.Enum):
# https://github.com/PyCQA/pylint/issues/2306
# pylint: disable=comparison-with-callable

def __ge__(self: ENUM_T, other: ENUM_T) -> bool:
def __ge__(self, other: ENUM_T) -> bool:
"""Return the greater than element."""
if self.__class__ is other.__class__:
return bool(self.value >= other.value)
return NotImplemented

def __gt__(self: ENUM_T, other: ENUM_T) -> bool:
def __gt__(self, other: ENUM_T) -> bool:
"""Return the greater element."""
if self.__class__ is other.__class__:
return bool(self.value > other.value)
return NotImplemented

def __le__(self: ENUM_T, other: ENUM_T) -> bool:
def __le__(self, other: ENUM_T) -> bool:
"""Return the lower than element."""
if self.__class__ is other.__class__:
return bool(self.value <= other.value)
return NotImplemented

def __lt__(self: ENUM_T, other: ENUM_T) -> bool:
def __lt__(self, other: ENUM_T) -> bool:
"""Return the lower element."""
if self.__class__ is other.__class__:
return bool(self.value < other.value)
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 @@ -65,7 +65,7 @@ def is_valid_unit(unit: str, unit_type: str) -> bool:
class UnitSystem:
"""A container for units of measure."""

def __init__(self: object, name: str, temperature: str, length: str,
def __init__(self, name: str, temperature: str, length: str,
volume: str, mass: str) -> None:
"""Initialize the unit system object."""
errors = \
Expand Down
Loading

0 comments on commit 1e5596b

Please sign in to comment.