Update pydocstyle to 2.1.1 and flake8-docstrings to 1.3.0 (#14557)

* Update pydocstyle to 2.1.1 and flake8-docstrings to 1.3.0

* Pydocstyle D401 fixes
This commit is contained in:
Ville Skyttä 2018-08-24 11:28:43 +03:00 committed by Paulus Schoutsen
parent 89d856d147
commit dd9d53c83e
84 changed files with 148 additions and 130 deletions

View file

@ -390,7 +390,7 @@ class AuthManager:
@callback @callback
def _async_get_auth_provider( def _async_get_auth_provider(
self, credentials: models.Credentials) -> Optional[AuthProvider]: self, credentials: models.Credentials) -> Optional[AuthProvider]:
"""Helper to get auth provider from a set of credentials.""" """Get auth provider from a set of credentials."""
auth_provider_key = (credentials.auth_provider_type, auth_provider_key = (credentials.auth_provider_type,
credentials.auth_provider_id) credentials.auth_provider_id)
return self._providers.get(auth_provider_key) return self._providers.get(auth_provider_key)

View file

@ -164,7 +164,7 @@ class HassAuthProvider(AuthProvider):
return HassLoginFlow(self) return HassLoginFlow(self)
async def async_validate_login(self, username: str, password: str) -> None: async def async_validate_login(self, username: str, password: str) -> None:
"""Helper to validate a username and password.""" """Validate a username and password."""
if self.data is None: if self.data is None:
await self.async_initialize() await self.async_initialize()
assert self.data is not None assert self.data is not None

View file

@ -38,7 +38,7 @@ class ExampleAuthProvider(AuthProvider):
@callback @callback
def async_validate_login(self, username: str, password: str) -> None: def async_validate_login(self, username: str, password: str) -> None:
"""Helper to validate a username and password.""" """Validate a username and password."""
user = None user = None
# Compare all users to avoid timing attacks. # Compare all users to avoid timing attacks.

View file

@ -43,7 +43,7 @@ class LegacyApiPasswordAuthProvider(AuthProvider):
@callback @callback
def async_validate_login(self, password: str) -> None: def async_validate_login(self, password: str) -> None:
"""Helper to validate a username and password.""" """Validate a username and password."""
hass_http = getattr(self.hass, 'http', None) # type: HomeAssistantHTTP hass_http = getattr(self.hass, 'http', None) # type: HomeAssistantHTTP
if not hmac.compare_digest(hass_http.api_password.encode('utf-8'), if not hmac.compare_digest(hass_http.api_password.encode('utf-8'),

View file

@ -71,7 +71,10 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:
"""Data update is triggered from BMWConnectedDriveEntity.""" """Return False.
Data update is triggered from BMWConnectedDriveEntity.
"""
return False return False
@property @property

View file

@ -58,7 +58,7 @@ class EgardiaBinarySensor(BinarySensorDevice):
@property @property
def name(self): def name(self):
"""The name of the device.""" """Return the name of the device."""
return self._name return self._name
@property @property
@ -74,5 +74,5 @@ class EgardiaBinarySensor(BinarySensorDevice):
@property @property
def device_class(self): def device_class(self):
"""The device class.""" """Return the device class."""
return self._device_class return self._device_class

View file

@ -183,7 +183,7 @@ class ONVIFHassCamera(Camera):
_LOGGER.debug("Camera '%s' doesn't support PTZ.", self._name) _LOGGER.debug("Camera '%s' doesn't support PTZ.", self._name)
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Callback when entity is added to hass.""" """Handle entity addition to hass."""
if ONVIF_DATA not in self.hass.data: if ONVIF_DATA not in self.hass.data:
self.hass.data[ONVIF_DATA] = {} self.hass.data[ONVIF_DATA] = {}
self.hass.data[ONVIF_DATA][ENTITIES] = [] self.hass.data[ONVIF_DATA][ENTITIES] = []

View file

@ -113,7 +113,7 @@ class PushCamera(Camera):
@property @property
def state(self): def state(self):
"""Current state of the camera.""" """Return current state of the camera."""
return self._state return self._state
async def update_image(self, image, filename): async def update_image(self, image, filename):

View file

@ -166,7 +166,7 @@ class MelissaClimate(ClimateDevice):
self.send({self._api.STATE: self._api.STATE_OFF}) self.send({self._api.STATE: self._api.STATE_OFF})
def send(self, value): def send(self, value):
"""Sending action to service.""" """Send action to service."""
try: try:
old_value = self._cur_settings.copy() old_value = self._cur_settings.copy()
self._cur_settings.update(value) self._cur_settings.update(value)

View file

@ -124,7 +124,7 @@ class NestThermostat(ClimateDevice):
@property @property
def unique_id(self): def unique_id(self):
"""Unique ID for this device.""" """Return unique ID for this device."""
return self._device.serial return self._device.serial
@property @property

View file

@ -100,7 +100,7 @@ class ZhongHongClimate(ClimateDevice):
async_dispatcher_send(self.hass, SIGNAL_DEVICE_ADDED) async_dispatcher_send(self.hass, SIGNAL_DEVICE_ADDED)
def _after_update(self, climate): def _after_update(self, climate):
"""Callback to update state.""" """Handle state update."""
_LOGGER.debug("async update ha state") _LOGGER.debug("async update ha state")
if self._device.current_operation: if self._device.current_operation:
self._current_operation = self._device.current_operation.lower() self._current_operation = self._device.current_operation.lower()

View file

@ -101,7 +101,7 @@ def websocket_update_entity(hass, connection, msg):
@callback @callback
def _entry_dict(entry): def _entry_dict(entry):
"""Helper to convert entry to API format.""" """Convert entry to API format."""
return { return {
'entity_id': entry.entity_id, 'entity_id': entry.entity_id,
'name': entry.name 'name': entry.name

View file

@ -212,7 +212,7 @@ class ZWaveProtectionView(HomeAssistantView):
network = hass.data.get(const.DATA_NETWORK) network = hass.data.get(const.DATA_NETWORK)
def _fetch_protection(): def _fetch_protection():
"""Helper to get protection data.""" """Get protection data."""
node = network.nodes.get(nodeid) node = network.nodes.get(nodeid)
if node is None: if node is None:
return self.json_message('Node not found', HTTP_NOT_FOUND) return self.json_message('Node not found', HTTP_NOT_FOUND)
@ -236,7 +236,7 @@ class ZWaveProtectionView(HomeAssistantView):
protection_data = await request.json() protection_data = await request.json()
def _set_protection(): def _set_protection():
"""Helper to get protection data.""" """Set protection data."""
node = network.nodes.get(nodeid) node = network.nodes.get(nodeid)
selection = protection_data["selection"] selection = protection_data["selection"]
value_id = int(protection_data[const.ATTR_VALUE_ID]) value_id = int(protection_data[const.ATTR_VALUE_ID])

View file

@ -82,7 +82,7 @@ async def async_setup_entry(hass, config_entry):
@callback @callback
def async_add_device_callback(device_type, device): def async_add_device_callback(device_type, device):
"""Called when a new device has been created in deCONZ.""" """Handle event of new device creation in deCONZ."""
async_dispatcher_send( async_dispatcher_send(
hass, 'deconz_new_{}'.format(device_type), [device]) hass, 'deconz_new_{}'.format(device_type), [device])

View file

@ -73,5 +73,8 @@ class XiaomiMiioDeviceScanner(DeviceScanner):
return devices return devices
async def async_get_device_name(self, device): async def async_get_device_name(self, device):
"""The repeater doesn't provide the name of the associated device.""" """Return None.
The repeater doesn't provide the name of the associated device.
"""
return None return None

View file

@ -139,17 +139,17 @@ class ConfiguredDoorbird():
@property @property
def name(self): def name(self):
"""Custom device name.""" """Get custom device name."""
return self._name return self._name
@property @property
def device(self): def device(self):
"""The configured device.""" """Get the configured device."""
return self._device return self._device
@property @property
def custom_url(self): def custom_url(self):
"""Custom url for device.""" """Get custom url for device."""
return self._custom_url return self._custom_url
@property @property

View file

@ -101,7 +101,7 @@ def setup(hass, config):
server.start() server.start()
def handle_stop_event(event): def handle_stop_event(event):
"""Callback function for HA stop event.""" """Handle HA stop event."""
server.stop() server.stop()
# listen to home assistant stop event # listen to home assistant stop event

View file

@ -49,7 +49,7 @@ TRAITS = []
def register_trait(trait): def register_trait(trait):
"""Decorator to register a trait.""" """Decorate a function to register a trait."""
TRAITS.append(trait) TRAITS.append(trait)
return trait return trait

View file

@ -550,12 +550,12 @@ class Group(Entity):
self._async_update_group_state() self._async_update_group_state()
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Callback when added to HASS.""" """Handle addition to HASS."""
if self.tracking: if self.tracking:
self.async_start() self.async_start()
async def async_will_remove_from_hass(self): async def async_will_remove_from_hass(self):
"""Callback when removed from HASS.""" """Handle removal from HASS."""
if self._async_unsub_state_changed: if self._async_unsub_state_changed:
self._async_unsub_state_changed() self._async_unsub_state_changed()
self._async_unsub_state_changed = None self._async_unsub_state_changed = None

View file

@ -27,17 +27,17 @@ _LOGGER = logging.getLogger(__name__)
def debounce(func): def debounce(func):
"""Decorator function. Debounce callbacks form HomeKit.""" """Decorate function to debounce callbacks from HomeKit."""
@ha_callback @ha_callback
def call_later_listener(self, *args): def call_later_listener(self, *args):
"""Callback listener called from call_later.""" """Handle call_later callback."""
debounce_params = self.debounce.pop(func.__name__, None) debounce_params = self.debounce.pop(func.__name__, None)
if debounce_params: if debounce_params:
self.hass.async_add_job(func, self, *debounce_params[1:]) self.hass.async_add_job(func, self, *debounce_params[1:])
@wraps(func) @wraps(func)
def wrapper(self, *args): def wrapper(self, *args):
"""Wrapper starts async timer.""" """Start async timer."""
debounce_params = self.debounce.pop(func.__name__, None) debounce_params = self.debounce.pop(func.__name__, None)
if debounce_params: if debounce_params:
debounce_params[0]() # remove listener debounce_params[0]() # remove listener
@ -88,7 +88,7 @@ class HomeAccessory(Accessory):
CHAR_STATUS_LOW_BATTERY, value=0) CHAR_STATUS_LOW_BATTERY, value=0)
async def run(self): async def run(self):
"""Method called by accessory after driver is started. """Handle accessory driver started event.
Run inside the HAP-python event loop. Run inside the HAP-python event loop.
""" """
@ -100,7 +100,7 @@ class HomeAccessory(Accessory):
@ha_callback @ha_callback
def update_state_callback(self, entity_id=None, old_state=None, def update_state_callback(self, entity_id=None, old_state=None,
new_state=None): new_state=None):
"""Callback from state change listener.""" """Handle state change listener callback."""
_LOGGER.debug('New_state: %s', new_state) _LOGGER.debug('New_state: %s', new_state)
if new_state is None: if new_state is None:
return return
@ -131,7 +131,7 @@ class HomeAccessory(Accessory):
hk_charging) hk_charging)
def update_state(self, new_state): def update_state(self, new_state):
"""Method called on state change to update HomeKit value. """Handle state change to update HomeKit value.
Overridden by accessory types. Overridden by accessory types.
""" """

View file

@ -71,7 +71,7 @@ async def ban_middleware(request, handler):
def log_invalid_auth(func): def log_invalid_auth(func):
"""Decorator to handle invalid auth or failed login attempts.""" """Decorate function to handle invalid auth or failed login attempts."""
async def handle_req(view, request, *args, **kwargs): async def handle_req(view, request, *args, **kwargs):
"""Try to log failed login attempts if response status >= 400.""" """Try to log failed login attempts if response status >= 400."""
resp = await func(view, request, *args, **kwargs) resp = await func(view, request, *args, **kwargs)

View file

@ -57,7 +57,7 @@ class IHCDevice(Entity):
} }
def on_ihc_change(self, ihc_id, value): def on_ihc_change(self, ihc_id, value):
"""Callback when IHC resource changes. """Handle IHC resource change.
Derived classes must overwrite this to do device specific stuff. Derived classes must overwrite this to do device specific stuff.
""" """

View file

@ -57,7 +57,7 @@ class IotaDevice(Entity):
"""Representation of a IOTA device.""" """Representation of a IOTA device."""
def __init__(self, name, seed, iri, is_testnet=False): def __init__(self, name, seed, iri, is_testnet=False):
"""Initialisation of the IOTA device.""" """Initialise the IOTA device."""
self._name = name self._name = name
self._seed = seed self._seed = seed
self.iri = iri self.iri = iri

View file

@ -334,7 +334,7 @@ class KNXExposeSensor:
self.hass, self.entity_id, self._async_entity_changed) self.hass, self.entity_id, self._async_entity_changed)
async def _async_entity_changed(self, entity_id, old_state, new_state): async def _async_entity_changed(self, entity_id, old_state, new_state):
"""Callback after entity changed.""" """Handle entity change."""
if new_state is None: if new_state is None:
return return
await self.device.set(float(new_state.state)) await self.device.set(float(new_state.state))

View file

@ -80,7 +80,7 @@ class LightGroup(light.Light):
await self.async_update() await self.async_update()
async def async_will_remove_from_hass(self): async def async_will_remove_from_hass(self):
"""Callback when removed from HASS.""" """Handle removal from HASS."""
if self._async_unsub_state_changed is not None: if self._async_unsub_state_changed is not None:
self._async_unsub_state_changed() self._async_unsub_state_changed()
self._async_unsub_state_changed = None self._async_unsub_state_changed = None

View file

@ -109,7 +109,7 @@ class IhcLight(IHCDevice, Light):
self.ihc_controller.set_runtime_value_bool(self.ihc_id, False) self.ihc_controller.set_runtime_value_bool(self.ihc_id, False)
def on_ihc_change(self, ihc_id, value): def on_ihc_change(self, ihc_id, value):
"""Callback from IHC notifications.""" """Handle IHC notifications."""
if isinstance(value, bool): if isinstance(value, bool):
self._dimmable = False self._dimmable = False
self._state = value != 0 self._state = value != 0

View file

@ -190,7 +190,7 @@ class LimitlessLEDGroup(Light):
@asyncio.coroutine @asyncio.coroutine
def async_added_to_hass(self): def async_added_to_hass(self):
"""Called when entity is about to be added to hass.""" """Handle entity about to be added to hass event."""
last_state = yield from async_get_last_state(self.hass, self.entity_id) last_state = yield from async_get_last_state(self.hass, self.entity_id)
if last_state: if last_state:
self._is_on = (last_state.state == STATE_ON) self._is_on = (last_state.state == STATE_ON)

View file

@ -53,7 +53,7 @@ class LW12WiFi(Light):
"""LW-12 WiFi LED Controller.""" """LW-12 WiFi LED Controller."""
def __init__(self, name, lw12_light): def __init__(self, name, lw12_light):
"""Initialisation of LW-12 WiFi LED Controller. """Initialise LW-12 WiFi LED Controller.
Args: Args:
name: Friendly name for this platform to use. name: Friendly name for this platform to use.

View file

@ -146,7 +146,7 @@ def _setup_internal_discovery(hass: HomeAssistantType) -> None:
import pychromecast import pychromecast
def internal_callback(name): def internal_callback(name):
"""Called when zeroconf has discovered a new chromecast.""" """Handle zeroconf discovery of a new chromecast."""
mdns = listener.services[name] mdns = listener.services[name]
_discover_chromecast(hass, ChromecastInfo(*mdns)) _discover_chromecast(hass, ChromecastInfo(*mdns))
@ -229,7 +229,7 @@ async def _async_setup_platform(hass: HomeAssistantType, config: ConfigType,
@callback @callback
def async_cast_discovered(discover: ChromecastInfo) -> None: def async_cast_discovered(discover: ChromecastInfo) -> None:
"""Callback for when a new chromecast is discovered.""" """Handle discovery of a new chromecast."""
if info is not None and info.host_port != discover.host_port: if info is not None and info.host_port != discover.host_port:
# Not our requested cast device. # Not our requested cast device.
return return
@ -277,17 +277,17 @@ class CastStatusListener:
chromecast.register_connection_listener(self) chromecast.register_connection_listener(self)
def new_cast_status(self, cast_status): def new_cast_status(self, cast_status):
"""Called when a new CastStatus is received.""" """Handle reception of a new CastStatus."""
if self._valid: if self._valid:
self._cast_device.new_cast_status(cast_status) self._cast_device.new_cast_status(cast_status)
def new_media_status(self, media_status): def new_media_status(self, media_status):
"""Called when a new MediaStatus is received.""" """Handle reception of a new MediaStatus."""
if self._valid: if self._valid:
self._cast_device.new_media_status(media_status) self._cast_device.new_media_status(media_status)
def new_connection_status(self, connection_status): def new_connection_status(self, connection_status):
"""Called when a new ConnectionStatus is received.""" """Handle reception of a new ConnectionStatus."""
if self._valid: if self._valid:
self._cast_device.new_connection_status(connection_status) self._cast_device.new_connection_status(connection_status)
@ -321,7 +321,7 @@ class CastDevice(MediaPlayerDevice):
"""Create chromecast object when added to hass.""" """Create chromecast object when added to hass."""
@callback @callback
def async_cast_discovered(discover: ChromecastInfo): def async_cast_discovered(discover: ChromecastInfo):
"""Callback for changing elected leaders / IP.""" """Handle discovery of new Chromecast."""
if self._cast_info.uuid is None: if self._cast_info.uuid is None:
# We can't handle empty UUIDs # We can't handle empty UUIDs
return return

View file

@ -70,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hass.data[DATA_CHANNELS].append(device) hass.data[DATA_CHANNELS].append(device)
def service_handler(service): def service_handler(service):
"""Handler for services.""" """Handle service."""
entity_id = service.data.get(ATTR_ENTITY_ID) entity_id = service.data.get(ATTR_ENTITY_ID)
device = next((device for device in hass.data[DATA_CHANNELS] if device = next((device for device in hass.data[DATA_CHANNELS] if

View file

@ -180,7 +180,7 @@ class DlnaDmrDevice(MediaPlayerDevice):
self._subscription_renew_time = None self._subscription_renew_time = None
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Callback when added.""" """Handle addition."""
self._device.on_event = self._on_event self._device.on_event = self._on_event
# register unsubscribe on stop # register unsubscribe on stop

View file

@ -103,7 +103,7 @@ class MediaroomDevice(MediaPlayerDevice):
"""Representation of a Mediaroom set-up-box on the network.""" """Representation of a Mediaroom set-up-box on the network."""
def set_state(self, mediaroom_state): def set_state(self, mediaroom_state):
"""Helper method to map pymediaroom states to HA states.""" """Map pymediaroom state to HA state."""
from pymediaroom import State from pymediaroom import State
state_map = { state_map = {

View file

@ -249,7 +249,7 @@ class XiaomiMiioRemote(RemoteDevice):
payload, ex) payload, ex)
def send_command(self, command, **kwargs): def send_command(self, command, **kwargs):
"""Wrapper for _send_command.""" """Send a command."""
num_repeats = kwargs.get(ATTR_NUM_REPEATS) num_repeats = kwargs.get(ATTR_NUM_REPEATS)
delay = kwargs.get(ATTR_DELAY_SECS, DEFAULT_DELAY_SECS) delay = kwargs.get(ATTR_DELAY_SECS, DEFAULT_DELAY_SECS)

View file

@ -193,7 +193,7 @@ def async_request_configuration(hass, config, host):
return return
def success(): def success():
"""Setup was successful.""" """Signal successful setup."""
conf = load_json(hass.config.path(CONFIG_FILE)) conf = load_json(hass.config.path(CONFIG_FILE))
conf[host] = {CONF_API_KEY: api_key} conf[host] = {CONF_API_KEY: api_key}
save_json(hass.config.path(CONFIG_FILE), conf) save_json(hass.config.path(CONFIG_FILE), conf)

View file

@ -58,7 +58,10 @@ class BMWConnectedDriveSensor(Entity):
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:
"""Data update is triggered from BMWConnectedDriveEntity.""" """Return False.
Data update is triggered from BMWConnectedDriveEntity.
"""
return False return False
@property @property

View file

@ -108,7 +108,7 @@ class FinTsClient:
""" """
def __init__(self, credentials: BankCredentials, name: str): def __init__(self, credentials: BankCredentials, name: str):
"""Constructor for class FinTsClient.""" """Initialize a FinTsClient."""
self._credentials = credentials self._credentials = credentials
self.name = name self.name = name
@ -158,7 +158,7 @@ class FinTsAccount(Entity):
""" """
def __init__(self, client: FinTsClient, account, name: str) -> None: def __init__(self, client: FinTsClient, account, name: str) -> None:
"""Constructor for class FinTsAccount.""" """Initialize a FinTs balance account."""
self._client = client # type: FinTsClient self._client = client # type: FinTsClient
self._account = account self._account = account
self._name = name # type: str self._name = name # type: str
@ -167,7 +167,10 @@ class FinTsAccount(Entity):
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:
"""Data needs to be polled from the bank servers.""" """Return True.
Data needs to be polled from the bank servers.
"""
return True return True
def update(self) -> None: def update(self) -> None:
@ -218,7 +221,7 @@ class FinTsHoldingsAccount(Entity):
""" """
def __init__(self, client: FinTsClient, account, name: str) -> None: def __init__(self, client: FinTsClient, account, name: str) -> None:
"""Constructor for class FinTsHoldingsAccount.""" """Initialize a FinTs holdings account."""
self._client = client # type: FinTsClient self._client = client # type: FinTsClient
self._name = name # type: str self._name = name # type: str
self._account = account self._account = account
@ -227,7 +230,10 @@ class FinTsHoldingsAccount(Entity):
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:
"""Data needs to be polled from the bank servers.""" """Return True.
Data needs to be polled from the bank servers.
"""
return True return True
def update(self) -> None: def update(self) -> None:

View file

@ -77,6 +77,6 @@ class IHCSensor(IHCDevice, Entity):
return self._unit_of_measurement return self._unit_of_measurement
def on_ihc_change(self, ihc_id, value): def on_ihc_change(self, ihc_id, value):
"""Callback when IHC resource changes.""" """Handle IHC resource change."""
self._state = value self._state = value
self.schedule_update_ha_state() self.schedule_update_ha_state()

View file

@ -72,7 +72,7 @@ class UscisSensor(Entity):
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self): def update(self):
"""Using Request to access USCIS website and fetch data.""" """Fetch data from the USCIS website and update state attributes."""
import uscisstatus import uscisstatus
try: try:
status = uscisstatus.get_case_status(self._case_id) status = uscisstatus.get_case_status(self._case_id)

View file

@ -98,7 +98,7 @@ class WirelessTagSensor(WirelessTagBaseSensor):
else all_sensors) else all_sensors)
def __init__(self, api, tag, sensor_type, config): def __init__(self, api, tag, sensor_type, config):
"""Constructor with platform(api), tag and hass sensor type.""" """Initialize a WirelessTag sensor."""
super().__init__(api, tag) super().__init__(api, tag)
self._sensor_type = sensor_type self._sensor_type = sensor_type

View file

@ -70,6 +70,6 @@ class IHCSwitch(IHCDevice, SwitchDevice):
self.ihc_controller.set_runtime_value_bool(self.ihc_id, False) self.ihc_controller.set_runtime_value_bool(self.ihc_id, False)
def on_ihc_change(self, ihc_id, value): def on_ihc_change(self, ihc_id, value):
"""Callback when the IHC resource changes.""" """Handle IHC resource change."""
self._state = value self._state = value
self.schedule_update_ha_state() self.schedule_update_ha_state()

View file

@ -77,7 +77,7 @@ class WemoSwitch(SwitchDevice):
self._async_locked_subscription_callback(not updated)) self._async_locked_subscription_callback(not updated))
async def _async_locked_subscription_callback(self, force_update): async def _async_locked_subscription_callback(self, force_update):
"""Helper to handle an update from a subscription.""" """Handle an update from a subscription."""
# If an update is in progress, we don't do anything # If an update is in progress, we don't do anything
if self._update_lock.locked(): if self._update_lock.locked():
return return

View file

@ -80,7 +80,7 @@ class WirelessTagPlatform:
# pylint: disable=no-self-use # pylint: disable=no-self-use
def make_push_notitication(self, name, url, content): def make_push_notitication(self, name, url, content):
"""Factory for notification config.""" """Create notification config."""
from wirelesstagpy import NotificationConfig from wirelesstagpy import NotificationConfig
return NotificationConfig(name, { return NotificationConfig(name, {
'url': url, 'verb': 'POST', 'url': url, 'verb': 'POST',
@ -129,7 +129,7 @@ class WirelessTagPlatform:
self.hass.config.api.base_url) self.hass.config.api.base_url)
def handle_update_tags_event(self, event): def handle_update_tags_event(self, event):
"""Main entry to handle push event from wireless tag manager.""" """Handle push event from wireless tag manager."""
_LOGGER.info("push notification for update arrived: %s", event) _LOGGER.info("push notification for update arrived: %s", event)
dispatcher_send( dispatcher_send(
self.hass, self.hass,
@ -215,7 +215,10 @@ class WirelessTagBaseSensor(Entity):
return 0 return 0
def updated_state_value(self): def updated_state_value(self):
"""Default implementation formats princial value.""" """Return formatted value.
The default implementation formats principal value.
"""
return self.decorate_value(self.principal_value) return self.decorate_value(self.principal_value)
# pylint: disable=no-self-use # pylint: disable=no-self-use

View file

@ -341,7 +341,7 @@ class Entity(entity.Entity):
application_listener.register_entity(ieee, self) application_listener.register_entity(ieee, self)
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Callback once the entity is added to hass. """Handle entity addition to hass.
It is now safe to update the entity state It is now safe to update the entity state
""" """

View file

@ -107,7 +107,7 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
@property @property
def unique_id(self): def unique_id(self):
"""Unique ID of Z-wave node.""" """Return unique ID of Z-wave node."""
return self._unique_id return self._unique_id
def network_node_changed(self, node=None, value=None, args=None): def network_node_changed(self, node=None, value=None, args=None):

View file

@ -87,7 +87,7 @@ class DeviceRegistry:
@callback @callback
def _data_to_save(self): def _data_to_save(self):
"""Data of device registry to store in a file.""" """Return data of device registry to store in a file."""
data = {} data = {}
data['devices'] = [ data['devices'] = [

View file

@ -378,7 +378,7 @@ class Entity:
@callback @callback
def async_registry_updated(self, old, new): def async_registry_updated(self, old, new):
"""Called when the entity registry has been updated.""" """Handle entity registry update."""
self.registry_name = new.name self.registry_name = new.name
if new.entity_id == self.entity_id: if new.entity_id == self.entity_id:

View file

@ -52,7 +52,7 @@ class EntityComponent:
in self._platforms.values()) in self._platforms.values())
def get_entity(self, entity_id): def get_entity(self, entity_id):
"""Helper method to get an entity.""" """Get an entity."""
for platform in self._platforms.values(): for platform in self._platforms.values():
entity = platform.entities.get(entity_id) entity = platform.entities.get(entity_id)
if entity is not None: if entity is not None:
@ -243,7 +243,7 @@ class EntityComponent:
def _async_init_entity_platform(self, platform_type, platform, def _async_init_entity_platform(self, platform_type, platform,
scan_interval=None, entity_namespace=None): scan_interval=None, entity_namespace=None):
"""Helper to initialize an entity platform.""" """Initialize an entity platform."""
if scan_interval is None: if scan_interval is None:
scan_interval = self.scan_interval scan_interval = self.scan_interval

View file

@ -106,7 +106,7 @@ class EntityPlatform:
return await self._async_setup_platform(async_create_setup_task) return await self._async_setup_platform(async_create_setup_task)
async def _async_setup_platform(self, async_create_setup_task, tries=0): async def _async_setup_platform(self, async_create_setup_task, tries=0):
"""Helper to set up a platform via config file or config entry. """Set up a platform via config file or config entry.
async_create_setup_task creates a coroutine that sets up platform. async_create_setup_task creates a coroutine that sets up platform.
""" """
@ -168,7 +168,7 @@ class EntityPlatform:
warn_task.cancel() warn_task.cancel()
def _schedule_add_entities(self, new_entities, update_before_add=False): def _schedule_add_entities(self, new_entities, update_before_add=False):
"""Synchronously schedule adding entities for a single platform.""" """Schedule adding entities for a single platform, synchronously."""
run_callback_threadsafe( run_callback_threadsafe(
self.hass.loop, self.hass.loop,
self._async_schedule_add_entities, list(new_entities), self._async_schedule_add_entities, list(new_entities),
@ -237,7 +237,7 @@ class EntityPlatform:
async def _async_add_entity(self, entity, update_before_add, async def _async_add_entity(self, entity, update_before_add,
component_entities, entity_registry, component_entities, entity_registry,
device_registry): device_registry):
"""Helper method to add an entity to the platform.""" """Add an entity to the platform."""
if entity is None: if entity is None:
raise ValueError('Entity cannot be None') raise ValueError('Entity cannot be None')

View file

@ -234,7 +234,7 @@ class EntityRegistry:
@callback @callback
def _data_to_save(self): def _data_to_save(self):
"""Data of entity registry to store in a file.""" """Return data of entity registry to store in a file."""
data = {} data = {}
data['entities'] = [ data['entities'] = [

View file

@ -18,12 +18,12 @@ _LOGGER = logging.getLogger(__name__)
async def async_migrator(hass, old_path, store, *, async def async_migrator(hass, old_path, store, *,
old_conf_load_func=json.load_json, old_conf_load_func=json.load_json,
old_conf_migrate_func=None): old_conf_migrate_func=None):
"""Helper function to migrate old data to a store and then load data. """Migrate old data to a store and then load data.
async def old_conf_migrate_func(old_data) async def old_conf_migrate_func(old_data)
""" """
def load_old_config(): def load_old_config():
"""Helper to load old config.""" """Load old config."""
if not os.path.isfile(old_path): if not os.path.isfile(old_path):
return None return None
@ -77,7 +77,7 @@ class Store:
return await self._load_task return await self._load_task
async def _async_load(self): async def _async_load(self):
"""Helper to load the data.""" """Load the data."""
# Check if we have a pending write # Check if we have a pending write
if self._data is not None: if self._data is not None:
data = self._data data = self._data
@ -165,7 +165,7 @@ class Store:
await self._async_handle_write_data() await self._async_handle_write_data()
async def _async_handle_write_data(self, *_args): async def _async_handle_write_data(self, *_args):
"""Handler to handle writing the config.""" """Handle writing the config."""
data = self._data data = self._data
if 'data_func' in data: if 'data_func' in data:

View file

@ -3,11 +3,11 @@
# new version # new version
asynctest==0.12.2 asynctest==0.12.2
coveralls==1.2.0 coveralls==1.2.0
flake8-docstrings==1.0.3 flake8-docstrings==1.3.0
flake8==3.5 flake8==3.5
mock-open==1.3.1 mock-open==1.3.1
mypy==0.620 mypy==0.620
pydocstyle==1.1.1 pydocstyle==2.1.1
pylint==2.1.1 pylint==2.1.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.5.1 pytest-cov==2.5.1

View file

@ -4,11 +4,11 @@
# new version # new version
asynctest==0.12.2 asynctest==0.12.2
coveralls==1.2.0 coveralls==1.2.0
flake8-docstrings==1.0.3 flake8-docstrings==1.3.0
flake8==3.5 flake8==3.5
mock-open==1.3.1 mock-open==1.3.1
mypy==0.620 mypy==0.620
pydocstyle==1.1.1 pydocstyle==2.1.1
pylint==2.1.1 pylint==2.1.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-cov==2.5.1 pytest-cov==2.5.1

View file

@ -156,7 +156,7 @@ def core_requirements():
def comment_requirement(req): def comment_requirement(req):
"""Some requirements don't install on all systems.""" """Comment out requirement. Some don't install on all systems."""
return any(ign in req for ign in COMMENT_REQUIREMENTS) return any(ign in req for ign in COMMENT_REQUIREMENTS)
@ -295,7 +295,7 @@ def validate_constraints_file(data):
def main(validate): def main(validate):
"""Main section of the script.""" """Run the script."""
if not os.path.isfile('requirements_all.txt'): if not os.path.isfile('requirements_all.txt'):
print('Run this from HA root dir') print('Run this from HA root dir')
return 1 return 1

View file

@ -18,7 +18,7 @@ def explore_module(package):
def main(): def main():
"""Main section of the script.""" """Run the script."""
if not os.path.isfile('requirements_all.txt'): if not os.path.isfile('requirements_all.txt'):
print('Run this from HA root dir') print('Run this from HA root dir')
return return

View file

@ -153,7 +153,7 @@ async def lint(files):
async def main(): async def main():
"""The main loop.""" """Run the main loop."""
# Ensure we are in the homeassistant root # Ensure we are in the homeassistant root
os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) os.chdir(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

View file

@ -88,7 +88,7 @@ def save_language_translations(lang, translations):
def main(): def main():
"""Main section of the script.""" """Run the script."""
if not os.path.isfile("requirements_all.txt"): if not os.path.isfile("requirements_all.txt"):
print("Run this from HA root dir") print("Run this from HA root dir")
return return

View file

@ -73,7 +73,7 @@ def get_translation_dict(translations, component, platform):
def main(): def main():
"""Main section of the script.""" """Run the script."""
if not os.path.isfile("requirements_all.txt"): if not os.path.isfile("requirements_all.txt"):
print("Run this from HA root dir") print("Run this from HA root dir")
return return

View file

@ -360,7 +360,7 @@ class MockUser(auth_models.User):
async def register_auth_provider(hass, config): async def register_auth_provider(hass, config):
"""Helper to register an auth provider.""" """Register an auth provider."""
provider = await auth_providers.auth_provider_from_config( provider = await auth_providers.auth_provider_from_config(
hass, hass.auth._store, config) hass, hass.auth._store, config)
assert provider is not None, 'Invalid config specified' assert provider is not None, 'Invalid config specified'
@ -749,7 +749,7 @@ class MockEntity(entity.Entity):
return self._handle('available') return self._handle('available')
def _handle(self, attr): def _handle(self, attr):
"""Helper for the attributes.""" """Return attribute value."""
if attr in self._values: if attr in self._values:
return self._values[attr] return self._values[attr]
return getattr(super(), attr) return getattr(super(), attr)

View file

@ -20,7 +20,7 @@ EMPTY_CONFIG = []
async def async_setup_auth(hass, aiohttp_client, provider_configs=BASE_CONFIG, async def async_setup_auth(hass, aiohttp_client, provider_configs=BASE_CONFIG,
module_configs=EMPTY_CONFIG, setup_api=False): module_configs=EMPTY_CONFIG, setup_api=False):
"""Helper to set up authentication and create an HTTP client.""" """Set up authentication and create an HTTP client."""
hass.auth = await auth.auth_manager_from_config( hass.auth = await auth.auth_manager_from_config(
hass, provider_configs, module_configs) hass, provider_configs, module_configs)
ensure_auth_manager_loaded(hass.auth) ensure_auth_manager_loaded(hass.auth)

View file

@ -5,7 +5,7 @@ from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI
async def async_get_code(hass, aiohttp_client): async def async_get_code(hass, aiohttp_client):
"""Helper for link user tests that returns authorization code.""" """Return authorization code for link user tests."""
config = [{ config = [{
'name': 'Example', 'name': 'Example',
'type': 'insecure_example', 'type': 'insecure_example',

View file

@ -20,7 +20,7 @@ class TestAutomationEvent(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper for recording the call.""" """Record the call."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -22,7 +22,7 @@ class TestAutomationMQTT(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper to record calls.""" """Record calls."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -25,7 +25,7 @@ class TestAutomationNumericState(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper to record calls.""" """Record calls."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -22,7 +22,7 @@ class TestAutomationTemplate(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper to record calls.""" """Record calls."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -25,7 +25,7 @@ class TestAutomationTime(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper to record calls.""" """Record calls."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -29,7 +29,7 @@ class TestAutomationZone(unittest.TestCase):
@callback @callback
def record_call(service): def record_call(service):
"""Helper to record calls.""" """Record calls."""
self.calls.append(service) self.calls.append(service)
self.hass.services.register('test', 'automation', record_call) self.hass.services.register('test', 'automation', record_call)

View file

@ -323,7 +323,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
@callback @callback
def listener(event): def listener(event):
"""Helper method that will verify our event got called.""" """Record that our event got called."""
test_events.append(event) test_events.append(event)
self.hass.bus.listen("device_tracker_new_device", listener) self.hass.bus.listen("device_tracker_new_device", listener)

View file

@ -11,7 +11,7 @@ from homeassistant.components.device_tracker.locative import URL
def _url(data=None): def _url(data=None):
"""Helper method to generate URLs.""" """Generate URL."""
data = data or {} data = data or {}
data = "&".join(["{}={}".format(name, value) for data = "&".join(["{}={}".format(name, value) for
name, value in data.items()]) name, value in data.items()])

View file

@ -15,7 +15,7 @@ class TestDemoFan(unittest.TestCase):
"""Test the fan demo platform.""" """Test the fan demo platform."""
def get_entity(self): def get_entity(self):
"""Helper method to get the fan entity.""" """Get the fan entity."""
return self.hass.states.get(FAN_ENTITY_ID) return self.hass.states.get(FAN_ENTITY_ID)
def setUp(self): def setUp(self):

View file

@ -8,7 +8,7 @@ from homeassistant.components.http.const import KEY_REAL_IP
async def mock_handler(request): async def mock_handler(request):
"""Handler that returns the real IP as text.""" """Return the real IP as text."""
return web.Response(text=str(request[KEY_REAL_IP])) return web.Response(text=str(request[KEY_REAL_IP]))

View file

@ -48,7 +48,7 @@ def get_fake_chromecast_info(host='192.168.178.42', port=8009,
async def async_setup_cast(hass, config=None, discovery_info=None): async def async_setup_cast(hass, config=None, discovery_info=None):
"""Helper to set up the cast platform.""" """Set up the cast platform."""
if config is None: if config is None:
config = {} config = {}
add_devices = Mock() add_devices = Mock()

View file

@ -52,7 +52,7 @@ class TestSamsungTv(unittest.TestCase):
@MockDependency('samsungctl') @MockDependency('samsungctl')
@MockDependency('wakeonlan') @MockDependency('wakeonlan')
def setUp(self, samsung_mock, wol_mock): def setUp(self, samsung_mock, wol_mock):
"""Setting up test environment.""" """Set up test environment."""
self.hass = tests.common.get_test_home_assistant() self.hass = tests.common.get_test_home_assistant()
self.hass.start() self.hass.start()
self.hass.block_till_done() self.hass.block_till_done()

View file

@ -94,7 +94,7 @@ class MockMediaPlayer(media_player.MediaPlayerDevice):
@property @property
def volume_level(self): def volume_level(self):
"""The volume level of player.""" """Return the volume level of player."""
return self._volume_level return self._volume_level
@property @property

View file

@ -56,7 +56,7 @@ class TestMQTTComponent(unittest.TestCase):
@callback @callback
def record_calls(self, *args): def record_calls(self, *args):
"""Helper for recording calls.""" """Record calls."""
self.calls.append(args) self.calls.append(args)
def aiohttp_client_stops_on_home_assistant_start(self): def aiohttp_client_stops_on_home_assistant_start(self):
@ -199,7 +199,7 @@ class TestMQTTCallbacks(unittest.TestCase):
@callback @callback
def record_calls(self, *args): def record_calls(self, *args):
"""Helper for recording calls.""" """Record calls."""
self.calls.append(args) self.calls.append(args)
def aiohttp_client_starts_on_home_assistant_mqtt_setup(self): def aiohttp_client_starts_on_home_assistant_mqtt_setup(self):

View file

@ -73,7 +73,7 @@ class TestNotifyDemo(unittest.TestCase):
@callback @callback
def record_calls(self, *args): def record_calls(self, *args):
"""Helper for recording calls.""" """Record calls."""
self.calls.append(args) self.calls.append(args)
def test_sending_none_message(self): def test_sending_none_message(self):

View file

@ -100,7 +100,7 @@ class YahooWeatherMock():
@property @property
def Now(self): # pylint: disable=invalid-name def Now(self): # pylint: disable=invalid-name
"""Current weather data.""" """Return current weather data."""
if self.woeid == '111': if self.woeid == '111':
raise ValueError raise ValueError
return self._data['query']['results']['channel']['item']['condition'] return self._data['query']['results']['channel']['item']['condition']

View file

@ -154,7 +154,7 @@ def test_api_fire_event_with_no_data(hass, mock_api_client):
@ha.callback @ha.callback
def listener(event): def listener(event):
"""Helper method that will verify our event got called.""" """Record that our event got called."""
test_value.append(1) test_value.append(1)
hass.bus.async_listen_once("test.event_no_data", listener) hass.bus.async_listen_once("test.event_no_data", listener)
@ -174,7 +174,7 @@ def test_api_fire_event_with_data(hass, mock_api_client):
@ha.callback @ha.callback
def listener(event): def listener(event):
"""Helper method that will verify that our event got called. """Record that our event got called.
Also test if our data came through. Also test if our data came through.
""" """
@ -200,7 +200,7 @@ def test_api_fire_event_with_invalid_json(hass, mock_api_client):
@ha.callback @ha.callback
def listener(event): def listener(event):
"""Helper method that will verify our event got called.""" """Record that our event got called."""
test_value.append(1) test_value.append(1)
hass.bus.async_listen_once("test_event_bad_data", listener) hass.bus.async_listen_once("test_event_bad_data", listener)
@ -281,7 +281,7 @@ def test_api_call_service_no_data(hass, mock_api_client):
@ha.callback @ha.callback
def listener(service_call): def listener(service_call):
"""Helper method that will verify that our service got called.""" """Record that our service got called."""
test_value.append(1) test_value.append(1)
hass.services.async_register("test_domain", "test_service", listener) hass.services.async_register("test_domain", "test_service", listener)
@ -300,7 +300,7 @@ def test_api_call_service_with_data(hass, mock_api_client):
@ha.callback @ha.callback
def listener(service_call): def listener(service_call):
"""Helper method that will verify that our service got called. """Record that our service got called.
Also test if our data came through. Also test if our data came through.
""" """
@ -440,7 +440,7 @@ async def test_api_fire_event_context(hass, mock_api_client,
@ha.callback @ha.callback
def listener(event): def listener(event):
"""Helper method that will verify our event got called.""" """Record that our event got called."""
test_value.append(event) test_value.append(event)
hass.bus.async_listen("test.event", listener) hass.bus.async_listen("test.event", listener)

View file

@ -47,7 +47,7 @@ def netdisco_mock():
async def mock_discovery(hass, discoveries, config=BASE_CONFIG): async def mock_discovery(hass, discoveries, config=BASE_CONFIG):
"""Helper to mock discoveries.""" """Mock discoveries."""
result = await async_setup_component(hass, 'discovery', config) result = await async_setup_component(hass, 'discovery', config)
assert result assert result

View file

@ -79,7 +79,7 @@ class TestFeedreaderComponent(unittest.TestCase):
VALID_CONFIG_3)) VALID_CONFIG_3))
def setup_manager(self, feed_data, max_entries=DEFAULT_MAX_ENTRIES): def setup_manager(self, feed_data, max_entries=DEFAULT_MAX_ENTRIES):
"""Generic test setup method.""" """Set up feed manager."""
events = [] events = []
@callback @callback

View file

@ -41,11 +41,11 @@ class PilightDaemonSim:
pass pass
def send_code(self, call): # pylint: disable=no-self-use def send_code(self, call): # pylint: disable=no-self-use
"""Called pilight.send service is called.""" """Handle pilight.send service callback."""
_LOGGER.error('PilightDaemonSim payload: ' + str(call)) _LOGGER.error('PilightDaemonSim payload: ' + str(call))
def start(self): def start(self):
"""Called homeassistant.start is called. """Handle homeassistant.start callback.
Also sends one test message after start up Also sends one test message after start up
""" """
@ -56,11 +56,11 @@ class PilightDaemonSim:
self.called = True self.called = True
def stop(self): # pylint: disable=no-self-use def stop(self): # pylint: disable=no-self-use
"""Called homeassistant.stop is called.""" """Handle homeassistant.stop callback."""
_LOGGER.error('PilightDaemonSim stop') _LOGGER.error('PilightDaemonSim stop')
def set_callback(self, function): def set_callback(self, function):
"""Callback called on event pilight.pilight_received.""" """Handle pilight.pilight_received event callback."""
self.callback = function self.callback = function
_LOGGER.error('PilightDaemonSim callback: ' + str(function)) _LOGGER.error('PilightDaemonSim callback: ' + str(function))

View file

@ -47,7 +47,7 @@ class MockResp(MagicMock):
@pytest.fixture @pytest.fixture
def mock_msearch_first(*args, **kwargs): def mock_msearch_first(*args, **kwargs):
"""Wrapper to async mock function.""" """Wrap async mock msearch_first."""
async def async_mock_msearch_first(*args, **kwargs): async def async_mock_msearch_first(*args, **kwargs):
"""Mock msearch_first.""" """Mock msearch_first."""
return MockResp(*args, **kwargs) return MockResp(*args, **kwargs)
@ -58,7 +58,7 @@ def mock_msearch_first(*args, **kwargs):
@pytest.fixture @pytest.fixture
def mock_async_exception(*args, **kwargs): def mock_async_exception(*args, **kwargs):
"""Wrapper to async mock function with exception.""" """Wrap async mock exception."""
async def async_mock_exception(*args, **kwargs): async def async_mock_exception(*args, **kwargs):
return Exception return Exception

View file

@ -41,31 +41,31 @@ class YahooWeatherMock():
@property @property
def RawData(self): # pylint: disable=invalid-name def RawData(self): # pylint: disable=invalid-name
"""Raw Data.""" """Return raw Data."""
if self.woeid == '12345': if self.woeid == '12345':
return json.loads('[]') return json.loads('[]')
return self._data return self._data
@property @property
def Now(self): # pylint: disable=invalid-name def Now(self): # pylint: disable=invalid-name
"""Current weather data.""" """Return current weather data."""
if self.woeid == '111': if self.woeid == '111':
raise ValueError raise ValueError
return self._data['query']['results']['channel']['item']['condition'] return self._data['query']['results']['channel']['item']['condition']
@property @property
def Atmosphere(self): # pylint: disable=invalid-name def Atmosphere(self): # pylint: disable=invalid-name
"""Atmosphere weather data.""" """Return atmosphere weather data."""
return self._data['query']['results']['channel']['atmosphere'] return self._data['query']['results']['channel']['atmosphere']
@property @property
def Wind(self): # pylint: disable=invalid-name def Wind(self): # pylint: disable=invalid-name
"""Wind weather data.""" """Return wind weather data."""
return self._data['query']['results']['channel']['wind'] return self._data['query']['results']['channel']['wind']
@property @property
def Forecast(self): # pylint: disable=invalid-name def Forecast(self): # pylint: disable=invalid-name
"""Forecast data 0-5 Days.""" """Return forecast data 0-5 Days."""
if self.woeid == '123123': if self.woeid == '123123':
raise ValueError raise ValueError
return self._data['query']['results']['channel']['item']['forecast'] return self._data['query']['results']['channel']['item']['forecast']

View file

@ -336,7 +336,7 @@ def test_raise_error_on_update(hass):
entity2 = MockEntity(name='test_2') entity2 = MockEntity(name='test_2')
def _raise(): def _raise():
"""Helper to raise an exception.""" """Raise an exception."""
raise AssertionError raise AssertionError
entity1.update = _raise entity1.update = _raise

View file

@ -257,7 +257,7 @@ class TestSetup:
def test_component_exception_setup(self): def test_component_exception_setup(self):
"""Test component that raises exception during setup.""" """Test component that raises exception during setup."""
def exception_setup(hass, config): def exception_setup(hass, config):
"""Setup that raises exception.""" """Raise exception."""
raise Exception('fail!') raise Exception('fail!')
loader.set_component( loader.set_component(
@ -269,7 +269,7 @@ class TestSetup:
def test_component_setup_with_validation_and_dependency(self): def test_component_setup_with_validation_and_dependency(self):
"""Test all config is passed to dependencies.""" """Test all config is passed to dependencies."""
def config_check_setup(hass, config): def config_check_setup(hass, config):
"""Setup method that tests config is passed in.""" """Test that config is passed in."""
if config.get('comp_a', {}).get('valid', False): if config.get('comp_a', {}).get('valid', False):
return True return True
raise Exception('Config not passed in: {}'.format(config)) raise Exception('Config not passed in: {}'.format(config))