move imports to top-level (#27630)
This commit is contained in:
parent
b7023a96a3
commit
1cae6e664c
1 changed files with 2 additions and 8 deletions
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue