From 1cae6e664c39f50c7254c80adf228e362e8099b9 Mon Sep 17 00:00:00 2001 From: Malte Franken <exxamalte@users.noreply.github.com> Date: Mon, 14 Oct 2019 19:56:40 +1100 Subject: [PATCH] move imports to top-level (#27630) --- homeassistant/components/pushover/notify.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/pushover/notify.py b/homeassistant/components/pushover/notify.py index 83da9a657fe..3f78897838d 100644 --- a/homeassistant/components/pushover/notify.py +++ b/homeassistant/components/pushover/notify.py @@ -1,7 +1,9 @@ """Pushover platform for notify component.""" import logging +import requests import voluptuous as vol +from pushover import InitError, Client, RequestError from homeassistant.const import CONF_API_KEY import homeassistant.helpers.config_validation as cv @@ -28,8 +30,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( def get_service(hass, config, discovery_info=None): """Get the Pushover notification service.""" - from pushover import InitError - try: return PushoverNotificationService( hass, config[CONF_USER_KEY], config[CONF_API_KEY] @@ -44,8 +44,6 @@ class PushoverNotificationService(BaseNotificationService): def __init__(self, hass, user_key, api_token): """Initialize the service.""" - from pushover import Client - self._hass = hass self._user_key = user_key self._api_token = api_token @@ -53,8 +51,6 @@ class PushoverNotificationService(BaseNotificationService): def send_message(self, message="", **kwargs): """Send a message to a user.""" - from pushover import RequestError - # Make a copy and use empty dict if necessary data = dict(kwargs.get(ATTR_DATA) or {}) @@ -65,8 +61,6 @@ class PushoverNotificationService(BaseNotificationService): # If attachment is a URL, use requests to open it as a stream. if data[ATTR_ATTACHMENT].startswith("http"): try: - import requests - response = requests.get( data[ATTR_ATTACHMENT], stream=True, timeout=5 ) -- GitLab