From 078e90717853790b75d1e6c01483631347ea7936 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Tue, 3 Dec 2019 12:23:41 +0100 Subject: [PATCH] Move imports to top for pushetta (#29332) * Move imports to top for pushetta * Make Pushetta.exceptions import lowercase and snakecase --- homeassistant/components/pushetta/notify.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/pushetta/notify.py b/homeassistant/components/pushetta/notify.py index b8911039f3f..c9b008524d6 100644 --- a/homeassistant/components/pushetta/notify.py +++ b/homeassistant/components/pushetta/notify.py @@ -1,17 +1,17 @@ """Pushetta platform for notify component.""" import logging +from pushetta import Pushetta, exceptions as pushetta_exceptions import voluptuous as vol -from homeassistant.const import CONF_API_KEY -import homeassistant.helpers.config_validation as cv - from homeassistant.components.notify import ( ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService, ) +from homeassistant.const import CONF_API_KEY +import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) @@ -44,7 +44,6 @@ class PushettaNotificationService(BaseNotificationService): def __init__(self, api_key, channel_name, send_test_msg): """Initialize the service.""" - from pushetta import Pushetta self._api_key = api_key self._channel_name = channel_name @@ -56,15 +55,14 @@ class PushettaNotificationService(BaseNotificationService): def send_message(self, message="", **kwargs): """Send a message to a user.""" - from pushetta import exceptions title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT) try: self.pushetta.pushMessage(self._channel_name, f"{title} {message}") - except exceptions.TokenValidationError: + except pushetta_exceptions.TokenValidationError: _LOGGER.error("Please check your access token") self.is_valid = False - except exceptions.ChannelNotFoundError: + except pushetta_exceptions.ChannelNotFoundError: _LOGGER.error("Channel '%s' not found", self._channel_name) self.is_valid = False