Skip to content

Commit

Permalink
Fix pylint warnings (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Oct 5, 2020
1 parent 17d8a9b commit 7aeba2a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
3 changes: 1 addition & 2 deletions custom_components/tahoma/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def icon(self) -> Optional[str]:
if self.device_class == DEVICE_CLASS_WATER:
if self.is_on:
return ICON_WATER
else:
return ICON_WATER_OFF
return ICON_WATER_OFF

icons = {DEVICE_CLASS_GAS: ICON_WAVES, DEVICE_CLASS_RAIN: ICON_WEATHER_RAINY}

Expand Down
9 changes: 2 additions & 7 deletions custom_components/tahoma/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Config flow for TaHoma integration."""
from asyncio import TimeoutError
import logging

from aiohttp import ClientError
Expand All @@ -12,12 +11,8 @@
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv

from .const import (
CONF_UPDATE_INTERVAL,
DEFAULT_UPDATE_INTERVAL,
DOMAIN,
MIN_UPDATE_INTERVAL,
)
from .const import CONF_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL, MIN_UPDATE_INTERVAL
from .const import DOMAIN # pylint: disable=unused-import

_LOGGER = logging.getLogger(__name__)

Expand Down
17 changes: 11 additions & 6 deletions custom_components/tahoma/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,27 @@ async def _async_update_data(self) -> Dict[str, Device]:
"""Fetch TaHoma data via event listener."""
try:
events = await self.client.fetch_events()
except BadCredentialsException:
raise UpdateFailed("invalid_auth")
except TooManyRequestsException:
raise UpdateFailed("too_many_requests")
except BadCredentialsException as exception:
raise UpdateFailed("invalid_auth") from exception
except TooManyRequestsException as exception:
raise UpdateFailed("too_many_requests") from exception
except (ServerDisconnectedError, NotAuthenticatedException):
self.executions = {}
await self.client.login()
self.devices = await self._get_devices()
return self.devices
except Exception as exception:
_LOGGER.debug(exception)
raise UpdateFailed(exception)
raise UpdateFailed(exception) from exception

for event in events:
_LOGGER.debug(
f"{event.name}/{event.exec_id} (device:{event.deviceurl},state:{event.old_state}->{event.new_state})"
"%s/%s (device: %s, state: %s -> %s)",
event.name,
event.exec_id,
event.deviceurl,
event.old_state,
event.new_state,
)

if event.name == EventName.DEVICE_AVAILABLE:
Expand Down
3 changes: 1 addition & 2 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ def icon(self):
):
if self.select_state(IO_PRIORITY_LOCK_ORIGINATOR_STATE) == "wind":
return ICON_WEATHER_WINDY
else:
return ICON_LOCK_ALERT
return ICON_LOCK_ALERT

return None

Expand Down
2 changes: 1 addition & 1 deletion custom_components/tahoma/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

try: # TODO: Remove for core PR. This ensures compatibility with <0.115
from homeassistant.const import PERCENTAGE
except Exception:
except Exception: # pylint: disable=broad-except
from homeassistant.const import UNIT_PERCENTAGE as PERCENTAGE


Expand Down
4 changes: 2 additions & 2 deletions custom_components/tahoma/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set_light_my_position:
example: "light.living_room"

set_cover_position_low_speed:
description: Move to specific position all or specified cover with a low speed.
description: Move to specific position all or specified cover with a low speed.
fields:
entity_id:
description: Name(s) of cover(s) to set cover position with a low speed.
Expand All @@ -33,4 +33,4 @@ execute_command:
example: "setIntensity"
args:
description: List of arguments to pass to the command if necessary
example: 100
example: 100
3 changes: 1 addition & 2 deletions custom_components/tahoma/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def icon(self) -> Optional[str]:
if self.device_class == DEVICE_CLASS_SIREN:
if self.is_on:
return ICON_BELL_RING
else:
return ICON_BELL_OFF
return ICON_BELL_OFF

return None

Expand Down
2 changes: 1 addition & 1 deletion custom_components/tahoma/tahoma_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def async_execute_command(self, command_name: str, *args: Any):
Command(command_name, list(args)),
"Home Assistant",
)
except Exception as exception:
except Exception as exception: # pylint: disable=broad-except
_LOGGER.error(exception)
return

Expand Down
1 change: 0 additions & 1 deletion tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pyhoma.exceptions import BadCredentialsException, TooManyRequestsException
import pytest
from asyncio import TimeoutError
from aiohttp import ClientError

from homeassistant import config_entries
Expand Down

0 comments on commit 7aeba2a

Please sign in to comment.