From 23b92b2a562d528dc8333f5cda59496f73016039 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 9 Dec 2019 14:38:01 +0100 Subject: [PATCH] Sort imports according to PEP8 for components starting with "S" (#29777) --- homeassistant/components/saj/sensor.py | 2 +- .../components/samsungtv/media_player.py | 6 +++--- homeassistant/components/scrape/sensor.py | 14 ++++++------- homeassistant/components/script/__init__.py | 21 +++++++++---------- homeassistant/components/sendgrid/notify.py | 18 +++++++--------- homeassistant/components/sensibo/climate.py | 4 ++-- .../components/shell_command/__init__.py | 2 +- homeassistant/components/sigfox/sensor.py | 4 ++-- homeassistant/components/simulated/sensor.py | 2 +- homeassistant/components/sinch/notify.py | 10 ++++----- .../components/sky_hub/device_tracker.py | 2 +- homeassistant/components/slide/__init__.py | 15 ++++++------- homeassistant/components/slide/cover.py | 9 ++++---- homeassistant/components/smtp/notify.py | 15 +++++++------ homeassistant/components/snips/__init__.py | 6 +++--- homeassistant/components/snmp/switch.py | 1 - .../components/solaredge_local/sensor.py | 10 ++++----- homeassistant/components/solax/sensor.py | 7 +++---- .../components/songpal/media_player.py | 14 ++++++------- homeassistant/components/splunk/__init__.py | 4 ++-- .../components/squeezebox/media_player.py | 2 +- homeassistant/components/ssdp/__init__.py | 2 +- homeassistant/components/suez_water/sensor.py | 5 ++--- homeassistant/components/sun/__init__.py | 5 ++--- .../components/supervisord/sensor.py | 2 +- .../components/synology_chat/notify.py | 5 ++--- .../components/samsungtv/test_media_player.py | 10 ++++----- tests/components/script/test_init.py | 9 ++++---- tests/components/season/test_sensor.py | 5 ++--- .../components/seventeentrack/test_sensor.py | 5 +++-- tests/components/shell_command/test_init.py | 4 ++-- tests/components/sigfox/test_sensor.py | 4 +++- .../components/simplisafe/test_config_flow.py | 4 ++-- tests/components/simulated/test_sensor.py | 8 +++---- .../smartthings/test_config_flow.py | 2 +- tests/components/smartthings/test_init.py | 2 +- tests/components/smhi/test_config_flow.py | 6 +++--- tests/components/smhi/test_weather.py | 17 +++++++-------- tests/components/smtp/test_notify.py | 2 +- tests/components/snips/test_init.py | 3 ++- .../components/solaredge/test_config_flow.py | 7 ++++--- tests/components/sonarr/test_sensor.py | 4 ++-- .../soundtouch/test_media_player.py | 4 +++- tests/components/spaceapi/test_init.py | 3 ++- tests/components/spc/test_init.py | 2 +- tests/components/splunk/test_init.py | 8 +++---- tests/components/ssdp/test_init.py | 4 ++-- tests/components/startca/test_sensor.py | 1 + tests/components/statistics/test_sensor.py | 18 ++++++++-------- tests/components/stt/test_init.py | 2 +- tests/components/sun/test_init.py | 4 ++-- tests/components/switcher_kis/test_init.py | 14 ++++++------- tests/components/system_log/test_init.py | 2 +- 53 files changed, 170 insertions(+), 171 deletions(-) diff --git a/homeassistant/components/saj/sensor.py b/homeassistant/components/saj/sensor.py index 52ae3640a7f..704e9996d2d 100644 --- a/homeassistant/components/saj/sensor.py +++ b/homeassistant/components/saj/sensor.py @@ -9,8 +9,8 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_HOST, - CONF_PASSWORD, CONF_NAME, + CONF_PASSWORD, CONF_TYPE, CONF_USERNAME, DEVICE_CLASS_POWER, diff --git a/homeassistant/components/samsungtv/media_player.py b/homeassistant/components/samsungtv/media_player.py index 2488d5ab913..56b947ba9ad 100644 --- a/homeassistant/components/samsungtv/media_player.py +++ b/homeassistant/components/samsungtv/media_player.py @@ -3,15 +3,15 @@ import asyncio from datetime import timedelta import socket -from samsungctl import exceptions as samsung_exceptions, Remote as SamsungRemote +from samsungctl import Remote as SamsungRemote, exceptions as samsung_exceptions import voluptuous as vol import wakeonlan from websocket import WebSocketException from homeassistant.components.media_player import ( - MediaPlayerDevice, - PLATFORM_SCHEMA, DEVICE_CLASS_TV, + PLATFORM_SCHEMA, + MediaPlayerDevice, ) from homeassistant.components.media_player.const import ( MEDIA_TYPE_CHANNEL, diff --git a/homeassistant/components/scrape/sensor.py b/homeassistant/components/scrape/sensor.py index 0bfb7351c88..13d99a0cb8f 100644 --- a/homeassistant/components/scrape/sensor.py +++ b/homeassistant/components/scrape/sensor.py @@ -2,27 +2,27 @@ import logging from bs4 import BeautifulSoup -import voluptuous as vol from requests.auth import HTTPBasicAuth, HTTPDigestAuth +import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.rest.sensor import RestData +from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( + CONF_AUTHENTICATION, + CONF_HEADERS, CONF_NAME, + CONF_PASSWORD, CONF_RESOURCE, CONF_UNIT_OF_MEASUREMENT, + CONF_USERNAME, CONF_VALUE_TEMPLATE, CONF_VERIFY_SSL, - CONF_USERNAME, - CONF_HEADERS, - CONF_PASSWORD, - CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION, ) -from homeassistant.helpers.entity import Entity from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index cb9cb5194ba..a8d78beae95 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -6,23 +6,22 @@ import voluptuous as vol from homeassistant.const import ( ATTR_ENTITY_ID, - SERVICE_TURN_OFF, - SERVICE_TURN_ON, - SERVICE_TOGGLE, - SERVICE_RELOAD, - STATE_ON, + ATTR_NAME, CONF_ALIAS, EVENT_SCRIPT_STARTED, - ATTR_NAME, + SERVICE_RELOAD, + SERVICE_TOGGLE, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, + STATE_ON, ) -from homeassistant.loader import bind_hass -from homeassistant.helpers.entity import ToggleEntity -from homeassistant.helpers.entity_component import EntityComponent import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import make_entity_service_schema -from homeassistant.helpers.service import async_set_service_schema - +from homeassistant.helpers.entity import ToggleEntity +from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.script import Script +from homeassistant.helpers.service import async_set_service_schema +from homeassistant.loader import bind_hass _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sendgrid/notify.py b/homeassistant/components/sendgrid/notify.py index f16758a5355..6dbf4d5c2b7 100644 --- a/homeassistant/components/sendgrid/notify.py +++ b/homeassistant/components/sendgrid/notify.py @@ -1,17 +1,8 @@ """SendGrid notification service.""" import logging -import voluptuous as vol - from sendgrid import SendGridAPIClient - -from homeassistant.const import ( - CONF_API_KEY, - CONF_RECIPIENT, - CONF_SENDER, - CONTENT_TYPE_TEXT_PLAIN, -) -import homeassistant.helpers.config_validation as cv +import voluptuous as vol from homeassistant.components.notify import ( ATTR_TITLE, @@ -19,6 +10,13 @@ from homeassistant.components.notify import ( PLATFORM_SCHEMA, BaseNotificationService, ) +from homeassistant.const import ( + CONF_API_KEY, + CONF_RECIPIENT, + CONF_SENDER, + CONTENT_TYPE_TEXT_PLAIN, +) +import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index a14bdb49133..2431b223f09 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -5,16 +5,16 @@ import logging import aiohttp import async_timeout -import voluptuous as vol import pysensibo +import voluptuous as vol from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateDevice from homeassistant.components.climate.const import ( - HVAC_MODE_HEAT_COOL, HVAC_MODE_COOL, HVAC_MODE_DRY, HVAC_MODE_FAN_ONLY, HVAC_MODE_HEAT, + HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, diff --git a/homeassistant/components/shell_command/__init__.py b/homeassistant/components/shell_command/__init__.py index 42057407814..89a1a20e8e4 100644 --- a/homeassistant/components/shell_command/__init__.py +++ b/homeassistant/components/shell_command/__init__.py @@ -5,8 +5,8 @@ import shlex import voluptuous as vol -from homeassistant.exceptions import TemplateError from homeassistant.core import ServiceCall +from homeassistant.exceptions import TemplateError from homeassistant.helpers import config_validation as cv, template from homeassistant.helpers.typing import ConfigType, HomeAssistantType diff --git a/homeassistant/components/sigfox/sensor.py b/homeassistant/components/sigfox/sensor.py index b890880389c..27e2fe9b563 100644 --- a/homeassistant/components/sigfox/sensor.py +++ b/homeassistant/components/sigfox/sensor.py @@ -1,15 +1,15 @@ """Sensor for SigFox devices.""" -import logging import datetime import json +import logging from urllib.parse import urljoin import requests import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_NAME +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/simulated/sensor.py b/homeassistant/components/simulated/sensor.py index f6ed54e5191..d05448a82c7 100644 --- a/homeassistant/components/simulated/sensor.py +++ b/homeassistant/components/simulated/sensor.py @@ -1,8 +1,8 @@ """Adds a simulated sensor.""" +from datetime import datetime import logging import math from random import Random -from datetime import datetime import voluptuous as vol diff --git a/homeassistant/components/sinch/notify.py b/homeassistant/components/sinch/notify.py index d7d1f242c67..c0092f013c4 100644 --- a/homeassistant/components/sinch/notify.py +++ b/homeassistant/components/sinch/notify.py @@ -1,25 +1,25 @@ """Support for Sinch notifications.""" import logging -import voluptuous as vol from clx.xms.api import MtBatchTextSmsResult from clx.xms.client import Client from clx.xms.exceptions import ( ErrorResponseException, - UnexpectedResponseException, - UnauthorizedException, NotFoundException, + UnauthorizedException, + UnexpectedResponseException, ) +import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.components.notify import ( - ATTR_MESSAGE, ATTR_DATA, + ATTR_MESSAGE, ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService, ) from homeassistant.const import CONF_API_KEY, CONF_SENDER +import homeassistant.helpers.config_validation as cv DOMAIN = "sinch" diff --git a/homeassistant/components/sky_hub/device_tracker.py b/homeassistant/components/sky_hub/device_tracker.py index 109c410c16d..f7760a59eed 100644 --- a/homeassistant/components/sky_hub/device_tracker.py +++ b/homeassistant/components/sky_hub/device_tracker.py @@ -5,13 +5,13 @@ import re import requests import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.components.device_tracker import ( DOMAIN, PLATFORM_SCHEMA, DeviceScanner, ) from homeassistant.const import CONF_HOST +import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) _MAC_REGEX = re.compile(r"(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})") diff --git a/homeassistant/components/slide/__init__.py b/homeassistant/components/slide/__init__.py index 54154ae863e..49e50e601dd 100644 --- a/homeassistant/components/slide/__init__.py +++ b/homeassistant/components/slide/__init__.py @@ -1,24 +1,25 @@ """Component for the Go Slide API.""" -import logging from datetime import timedelta +import logging -import voluptuous as vol from goslideapi import GoSlideCloud, goslideapi +import voluptuous as vol from homeassistant.const import ( - CONF_USERNAME, CONF_PASSWORD, CONF_SCAN_INTERVAL, - STATE_OPEN, + CONF_USERNAME, STATE_CLOSED, - STATE_OPENING, STATE_CLOSING, + STATE_OPEN, + STATE_OPENING, ) from homeassistant.helpers import config_validation as cv from homeassistant.helpers.discovery import async_load_platform -from homeassistant.helpers.event import async_track_time_interval, async_call_later -from .const import DOMAIN, SLIDES, API, COMPONENT, DEFAULT_RETRY +from homeassistant.helpers.event import async_call_later, async_track_time_interval + +from .const import API, COMPONENT, DEFAULT_RETRY, DOMAIN, SLIDES _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/slide/cover.py b/homeassistant/components/slide/cover.py index 1c4e6da5aac..a567a9bf61b 100644 --- a/homeassistant/components/slide/cover.py +++ b/homeassistant/components/slide/cover.py @@ -2,15 +2,16 @@ import logging -from homeassistant.const import ATTR_ID from homeassistant.components.cover import ( ATTR_POSITION, - STATE_CLOSED, - STATE_OPENING, - STATE_CLOSING, DEVICE_CLASS_CURTAIN, + STATE_CLOSED, + STATE_CLOSING, + STATE_OPENING, CoverDevice, ) +from homeassistant.const import ATTR_ID + from .const import API, DOMAIN, SLIDES _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/smtp/notify.py b/homeassistant/components/smtp/notify.py index d592f25a61d..82b0f96f785 100644 --- a/homeassistant/components/smtp/notify.py +++ b/homeassistant/components/smtp/notify.py @@ -10,6 +10,13 @@ import smtplib import voluptuous as vol +from homeassistant.components.notify import ( + ATTR_DATA, + ATTR_TITLE, + ATTR_TITLE_DEFAULT, + PLATFORM_SCHEMA, + BaseNotificationService, +) from homeassistant.const import ( CONF_PASSWORD, CONF_PORT, @@ -21,14 +28,6 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv import homeassistant.util.dt as dt_util -from homeassistant.components.notify import ( - ATTR_DATA, - ATTR_TITLE, - ATTR_TITLE_DEFAULT, - PLATFORM_SCHEMA, - BaseNotificationService, -) - _LOGGER = logging.getLogger(__name__) ATTR_IMAGES = "images" # optional embedded image file attachments diff --git a/homeassistant/components/snips/__init__.py b/homeassistant/components/snips/__init__.py index 93e445e8ced..65015bd723c 100644 --- a/homeassistant/components/snips/__init__.py +++ b/homeassistant/components/snips/__init__.py @@ -1,13 +1,13 @@ """Support for Snips on-device ASR and NLU.""" +from datetime import timedelta import json import logging -from datetime import timedelta import voluptuous as vol -from homeassistant.core import callback -from homeassistant.helpers import intent, config_validation as cv from homeassistant.components import mqtt +from homeassistant.core import callback +from homeassistant.helpers import config_validation as cv, intent DOMAIN = "snips" CONF_INTENTS = "intents" diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index 8d5be1221c4..578b97c801e 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -2,7 +2,6 @@ import logging from pyasn1.type.univ import Integer - import pysnmp.hlapi.asyncio as hlapi from pysnmp.hlapi.asyncio import ( CommunityData, diff --git a/homeassistant/components/solaredge_local/sensor.py b/homeassistant/components/solaredge_local/sensor.py index 917fb86ddcb..ecf9dfde8b1 100644 --- a/homeassistant/components/solaredge_local/sensor.py +++ b/homeassistant/components/solaredge_local/sensor.py @@ -1,10 +1,10 @@ """Support for SolarEdge-local Monitoring API.""" -import logging -from datetime import timedelta -import statistics from copy import deepcopy +from datetime import timedelta +import logging +import statistics -from requests.exceptions import HTTPError, ConnectTimeout +from requests.exceptions import ConnectTimeout, HTTPError from solaredge_local import SolarEdge import voluptuous as vol @@ -12,8 +12,8 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( CONF_IP_ADDRESS, CONF_NAME, - POWER_WATT, ENERGY_WATT_HOUR, + POWER_WATT, TEMP_CELSIUS, TEMP_FAHRENHEIT, ) diff --git a/homeassistant/components/solax/sensor.py b/homeassistant/components/solax/sensor.py index a5b4547b344..8eb61560e63 100644 --- a/homeassistant/components/solax/sensor.py +++ b/homeassistant/components/solax/sensor.py @@ -1,6 +1,5 @@ """Support for Solax inverter via local API.""" import asyncio - from datetime import timedelta import logging @@ -8,11 +7,11 @@ from solax import real_time_api from solax.inverter import InverterError import voluptuous as vol -from homeassistant.const import TEMP_CELSIUS, CONF_IP_ADDRESS, CONF_PORT -from homeassistant.helpers.entity import Entity -import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA +from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, TEMP_CELSIUS from homeassistant.exceptions import PlatformNotReady +import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/songpal/media_player.py b/homeassistant/components/songpal/media_player.py index 681c97a7710..27a81b2a667 100644 --- a/homeassistant/components/songpal/media_player.py +++ b/homeassistant/components/songpal/media_player.py @@ -1,19 +1,19 @@ """Support for Songpal-enabled (Sony) media devices.""" import asyncio -import logging from collections import OrderedDict +import logging -import voluptuous as vol from songpal import ( + ConnectChange, + ContentChange, Device, + PowerChange, SongpalException, VolumeChange, - ContentChange, - PowerChange, - ConnectChange, ) +import voluptuous as vol -from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA +from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice from homeassistant.components.media_player.const import ( SUPPORT_SELECT_SOURCE, SUPPORT_TURN_OFF, @@ -25,9 +25,9 @@ from homeassistant.components.media_player.const import ( from homeassistant.const import ( ATTR_ENTITY_ID, CONF_NAME, + EVENT_HOMEASSISTANT_STOP, STATE_OFF, STATE_ON, - EVENT_HOMEASSISTANT_STOP, ) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/splunk/__init__.py b/homeassistant/components/splunk/__init__.py index c483d7fae87..1d5d39416a3 100644 --- a/homeassistant/components/splunk/__init__.py +++ b/homeassistant/components/splunk/__init__.py @@ -7,12 +7,12 @@ import requests import voluptuous as vol from homeassistant.const import ( - CONF_SSL, - CONF_VERIFY_SSL, CONF_HOST, CONF_NAME, CONF_PORT, + CONF_SSL, CONF_TOKEN, + CONF_VERIFY_SSL, EVENT_STATE_CHANGED, ) from homeassistant.helpers import state as state_helper diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 72a5772a14d..94c497e4db6 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -38,9 +38,9 @@ from homeassistant.const import ( STATE_PAUSED, STATE_PLAYING, ) +from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession import homeassistant.helpers.config_validation as cv -from homeassistant.exceptions import PlatformNotReady from homeassistant.util.dt import utcnow from .const import DOMAIN, SERVICE_CALL_METHOD diff --git a/homeassistant/components/ssdp/__init__.py b/homeassistant/components/ssdp/__init__.py index b9a9d4b46c9..1a97b1721fc 100644 --- a/homeassistant/components/ssdp/__init__.py +++ b/homeassistant/components/ssdp/__init__.py @@ -8,8 +8,8 @@ import aiohttp from defusedxml import ElementTree from netdisco import ssdp, util -from homeassistant.helpers.event import async_track_time_interval from homeassistant.generated.ssdp import SSDP +from homeassistant.helpers.event import async_track_time_interval DOMAIN = "ssdp" SCAN_INTERVAL = timedelta(seconds=60) diff --git a/homeassistant/components/suez_water/sensor.py b/homeassistant/components/suez_water/sensor.py index 05f82183e46..bfa529adb34 100644 --- a/homeassistant/components/suez_water/sensor.py +++ b/homeassistant/components/suez_water/sensor.py @@ -2,10 +2,9 @@ from datetime import timedelta import logging -import voluptuous as vol - -from pysuez.client import PySuezError from pysuez import SuezClient +from pysuez.client import PySuezError +import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, VOLUME_LITERS diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py index e848449e61e..704f9432a0f 100644 --- a/homeassistant/components/sun/__init__.py +++ b/homeassistant/components/sun/__init__.py @@ -1,12 +1,12 @@ """Support for functionality to keep track of the sun.""" -import logging from datetime import timedelta +import logging from homeassistant.const import ( CONF_ELEVATION, + EVENT_CORE_CONFIG_UPDATE, SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET, - EVENT_CORE_CONFIG_UPDATE, ) from homeassistant.core import callback from homeassistant.helpers.entity import Entity @@ -17,7 +17,6 @@ from homeassistant.helpers.sun import ( ) from homeassistant.util import dt as dt_util - # mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/supervisord/sensor.py b/homeassistant/components/supervisord/sensor.py index e1a816f91ae..c79c09248b4 100644 --- a/homeassistant/components/supervisord/sensor.py +++ b/homeassistant/components/supervisord/sensor.py @@ -6,8 +6,8 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_URL -from homeassistant.helpers.entity import Entity import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/synology_chat/notify.py b/homeassistant/components/synology_chat/notify.py index c67ef79f5d5..3e1aeb4ce13 100644 --- a/homeassistant/components/synology_chat/notify.py +++ b/homeassistant/components/synology_chat/notify.py @@ -5,14 +5,13 @@ import logging import requests import voluptuous as vol -from homeassistant.const import CONF_RESOURCE, CONF_VERIFY_SSL -import homeassistant.helpers.config_validation as cv - from homeassistant.components.notify import ( ATTR_DATA, PLATFORM_SCHEMA, BaseNotificationService, ) +from homeassistant.const import CONF_RESOURCE, CONF_VERIFY_SSL +import homeassistant.helpers.config_validation as cv ATTR_FILE_URL = "file_url" diff --git a/tests/components/samsungtv/test_media_player.py b/tests/components/samsungtv/test_media_player.py index 918e30ef4e7..bb40dc28445 100644 --- a/tests/components/samsungtv/test_media_player.py +++ b/tests/components/samsungtv/test_media_player.py @@ -1,13 +1,12 @@ """Tests for samsungtv component.""" import asyncio -from unittest.mock import call, patch from datetime import timedelta - import logging +from unittest.mock import call, patch + from asynctest import mock import pytest from samsungctl import exceptions -from tests.common import async_fire_time_changed from websocket import WebSocketException from homeassistant.components.media_player import DEVICE_CLASS_TV @@ -17,11 +16,11 @@ from homeassistant.components.media_player.const import ( ATTR_MEDIA_CONTENT_TYPE, ATTR_MEDIA_VOLUME_MUTED, DOMAIN, + MEDIA_TYPE_CHANNEL, + MEDIA_TYPE_URL, SERVICE_PLAY_MEDIA, SERVICE_SELECT_SOURCE, SUPPORT_TURN_ON, - MEDIA_TYPE_CHANNEL, - MEDIA_TYPE_URL, ) from homeassistant.components.samsungtv.const import DOMAIN as SAMSUNGTV_DOMAIN from homeassistant.components.samsungtv.media_player import ( @@ -56,6 +55,7 @@ from homeassistant.helpers.discovery import async_load_platform from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util +from tests.common import async_fire_time_changed ENTITY_ID = f"{DOMAIN}.fake" MOCK_CONFIG = { diff --git a/tests/components/script/test_init.py b/tests/components/script/test_init.py index d675034e744..697154c46b2 100644 --- a/tests/components/script/test_init.py +++ b/tests/components/script/test_init.py @@ -1,7 +1,7 @@ """The tests for the Script component.""" # pylint: disable=protected-access import unittest -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch import pytest @@ -10,21 +10,20 @@ from homeassistant.components.script import DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_NAME, + EVENT_SCRIPT_STARTED, SERVICE_RELOAD, SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON, - EVENT_SCRIPT_STARTED, ) from homeassistant.core import Context, callback, split_entity_id +from homeassistant.exceptions import ServiceNotFound from homeassistant.helpers.service import async_get_all_descriptions from homeassistant.loader import bind_hass -from homeassistant.setup import setup_component, async_setup_component -from homeassistant.exceptions import ServiceNotFound +from homeassistant.setup import async_setup_component, setup_component from tests.common import get_test_home_assistant - ENTITY_ID = "script.test" diff --git a/tests/components/season/test_sensor.py b/tests/components/season/test_sensor.py index 9d891fe0155..2acc5f6573f 100644 --- a/tests/components/season/test_sensor.py +++ b/tests/components/season/test_sensor.py @@ -1,14 +1,13 @@ """The tests for the Season sensor platform.""" # pylint: disable=protected-access -import unittest from datetime import datetime +import unittest -from homeassistant.setup import setup_component import homeassistant.components.season.sensor as season +from homeassistant.setup import setup_component from tests.common import get_test_home_assistant - HEMISPHERE_NORTHERN = { "homeassistant": {"latitude": "48.864716", "longitude": "2.349014"}, "sensor": {"platform": "season", "type": "astronomical"}, diff --git a/tests/components/seventeentrack/test_sensor.py b/tests/components/seventeentrack/test_sensor.py index 45ab8a62225..10ec22f8b67 100644 --- a/tests/components/seventeentrack/test_sensor.py +++ b/tests/components/seventeentrack/test_sensor.py @@ -2,17 +2,18 @@ import datetime from typing import Union -import pytest import mock from py17track.package import Package +import pytest from homeassistant.components.seventeentrack.sensor import ( CONF_SHOW_ARCHIVED, CONF_SHOW_DELIVERED, ) -from homeassistant.const import CONF_USERNAME, CONF_PASSWORD +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.setup import async_setup_component from homeassistant.util import utcnow + from tests.common import MockDependency, async_fire_time_changed VALID_CONFIG_MINIMAL = { diff --git a/tests/components/shell_command/test_init.py b/tests/components/shell_command/test_init.py index 13899da9a3e..a54bd9f7787 100644 --- a/tests/components/shell_command/test_init.py +++ b/tests/components/shell_command/test_init.py @@ -2,12 +2,12 @@ import asyncio import os import tempfile -import unittest from typing import Tuple +import unittest from unittest.mock import Mock, patch -from homeassistant.setup import setup_component from homeassistant.components import shell_command +from homeassistant.setup import setup_component from tests.common import get_test_home_assistant diff --git a/tests/components/sigfox/test_sensor.py b/tests/components/sigfox/test_sensor.py index eac1e6c2582..35534a3a126 100644 --- a/tests/components/sigfox/test_sensor.py +++ b/tests/components/sigfox/test_sensor.py @@ -1,14 +1,16 @@ """Tests for the sigfox sensor.""" import re -import requests_mock import unittest +import requests_mock + from homeassistant.components.sigfox.sensor import ( API_URL, CONF_API_LOGIN, CONF_API_PASSWORD, ) from homeassistant.setup import setup_component + from tests.common import get_test_home_assistant TEST_API_LOGIN = "foo" diff --git a/tests/components/simplisafe/test_config_flow.py b/tests/components/simplisafe/test_config_flow.py index c0920a738ee..a7a21c577d6 100644 --- a/tests/components/simplisafe/test_config_flow.py +++ b/tests/components/simplisafe/test_config_flow.py @@ -1,7 +1,7 @@ """Define tests for the SimpliSafe config flow.""" -import json from datetime import timedelta -from unittest.mock import mock_open, patch, MagicMock, PropertyMock +import json +from unittest.mock import MagicMock, PropertyMock, mock_open, patch from homeassistant import data_entry_flow from homeassistant.components.simplisafe import DOMAIN, config_flow diff --git a/tests/components/simulated/test_sensor.py b/tests/components/simulated/test_sensor.py index 14d839ee656..09e77f7b283 100644 --- a/tests/components/simulated/test_sensor.py +++ b/tests/components/simulated/test_sensor.py @@ -1,28 +1,28 @@ """The tests for the simulated sensor.""" import unittest -from tests.common import get_test_home_assistant - from homeassistant.components.simulated.sensor import ( CONF_AMP, CONF_FWHM, CONF_MEAN, CONF_PERIOD, CONF_PHASE, + CONF_RELATIVE_TO_EPOCH, CONF_SEED, CONF_UNIT, - CONF_RELATIVE_TO_EPOCH, DEFAULT_AMP, DEFAULT_FWHM, DEFAULT_MEAN, DEFAULT_NAME, DEFAULT_PHASE, - DEFAULT_SEED, DEFAULT_RELATIVE_TO_EPOCH, + DEFAULT_SEED, ) from homeassistant.const import CONF_FRIENDLY_NAME from homeassistant.setup import setup_component +from tests.common import get_test_home_assistant + class TestSimulatedSensor(unittest.TestCase): """Test the simulated sensor.""" diff --git a/tests/components/smartthings/test_config_flow.py b/tests/components/smartthings/test_config_flow.py index 82a24f38287..f299727b948 100644 --- a/tests/components/smartthings/test_config_flow.py +++ b/tests/components/smartthings/test_config_flow.py @@ -6,7 +6,6 @@ from asynctest import Mock, patch from pysmartthings import APIResponseError from homeassistant import data_entry_flow -from homeassistant.setup import async_setup_component from homeassistant.components.smartthings import smartapp from homeassistant.components.smartthings.config_flow import SmartThingsFlowHandler from homeassistant.components.smartthings.const import ( @@ -16,6 +15,7 @@ from homeassistant.components.smartthings.const import ( CONF_REFRESH_TOKEN, DOMAIN, ) +from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry, mock_coro diff --git a/tests/components/smartthings/test_init.py b/tests/components/smartthings/test_init.py index b8cd65f5a0b..0c9d889d558 100644 --- a/tests/components/smartthings/test_init.py +++ b/tests/components/smartthings/test_init.py @@ -6,7 +6,6 @@ from asynctest import Mock, patch from pysmartthings import InstalledAppStatus, OAuthToken import pytest -from homeassistant.setup import async_setup_component from homeassistant.components import cloud, smartthings from homeassistant.components.smartthings.const import ( CONF_CLOUDHOOK_URL, @@ -20,6 +19,7 @@ from homeassistant.components.smartthings.const import ( ) from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry diff --git a/tests/components/smhi/test_config_flow.py b/tests/components/smhi/test_config_flow.py index e5e1d392419..ceccd75e08d 100644 --- a/tests/components/smhi/test_config_flow.py +++ b/tests/components/smhi/test_config_flow.py @@ -3,10 +3,10 @@ from unittest.mock import Mock, patch from smhi.smhi_lib import Smhi as SmhiApi, SmhiForecastException -from tests.common import mock_coro - -from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE from homeassistant.components.smhi import config_flow +from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE + +from tests.common import mock_coro # pylint: disable=protected-access diff --git a/tests/components/smhi/test_weather.py b/tests/components/smhi/test_weather.py index 6cb7d690c1c..92557f9d543 100644 --- a/tests/components/smhi/test_weather.py +++ b/tests/components/smhi/test_weather.py @@ -1,31 +1,30 @@ """Test for the smhi weather entity.""" import asyncio -import logging from datetime import datetime +import logging from unittest.mock import Mock, patch +from homeassistant.components.smhi import weather as weather_smhi +from homeassistant.components.smhi.const import ATTR_SMHI_CLOUDINESS from homeassistant.components.weather import ( ATTR_FORECAST_CONDITION, + ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_TEMP, + ATTR_FORECAST_TEMP_LOW, ATTR_FORECAST_TIME, - ATTR_WEATHER_TEMPERATURE, + ATTR_WEATHER_ATTRIBUTION, ATTR_WEATHER_HUMIDITY, ATTR_WEATHER_PRESSURE, - ATTR_FORECAST_TEMP_LOW, + ATTR_WEATHER_TEMPERATURE, ATTR_WEATHER_VISIBILITY, - ATTR_WEATHER_ATTRIBUTION, ATTR_WEATHER_WIND_BEARING, ATTR_WEATHER_WIND_SPEED, - ATTR_FORECAST_PRECIPITATION, DOMAIN as WEATHER_DOMAIN, ) -from homeassistant.components.smhi import weather as weather_smhi from homeassistant.const import TEMP_CELSIUS from homeassistant.core import HomeAssistant -from tests.common import load_fixture, MockConfigEntry - -from homeassistant.components.smhi.const import ATTR_SMHI_CLOUDINESS +from tests.common import MockConfigEntry, load_fixture _LOGGER = logging.getLogger(__name__) diff --git a/tests/components/smtp/test_notify.py b/tests/components/smtp/test_notify.py index daef7ef130e..c79633dd02d 100644 --- a/tests/components/smtp/test_notify.py +++ b/tests/components/smtp/test_notify.py @@ -1,11 +1,11 @@ """The tests for the notify smtp platform.""" +import re import unittest from unittest.mock import patch from homeassistant.components.smtp.notify import MailNotificationService from tests.common import get_test_home_assistant -import re class MockSMTP(MailNotificationService): diff --git a/tests/components/snips/test_init.py b/tests/components/snips/test_init.py index fa6fbe0b254..40fb30ddd19 100644 --- a/tests/components/snips/test_init.py +++ b/tests/components/snips/test_init.py @@ -9,11 +9,12 @@ from homeassistant.bootstrap import async_setup_component from homeassistant.components.mqtt import MQTT_PUBLISH_SCHEMA import homeassistant.components.snips as snips from homeassistant.helpers.intent import ServiceIntentHandler, async_register + from tests.common import ( async_fire_mqtt_message, async_mock_intent, - async_mock_service, async_mock_mqtt_component, + async_mock_service, ) diff --git a/tests/components/solaredge/test_config_flow.py b/tests/components/solaredge/test_config_flow.py index c1183147bac..46f40dd80ef 100644 --- a/tests/components/solaredge/test_config_flow.py +++ b/tests/components/solaredge/test_config_flow.py @@ -1,12 +1,13 @@ """Tests for the SolarEdge config flow.""" +from unittest.mock import Mock, patch + import pytest -from requests.exceptions import HTTPError, ConnectTimeout -from unittest.mock import patch, Mock +from requests.exceptions import ConnectTimeout, HTTPError from homeassistant import data_entry_flow from homeassistant.components.solaredge import config_flow from homeassistant.components.solaredge.const import CONF_SITE_ID, DEFAULT_NAME -from homeassistant.const import CONF_NAME, CONF_API_KEY +from homeassistant.const import CONF_API_KEY, CONF_NAME from tests.common import MockConfigEntry diff --git a/tests/components/sonarr/test_sensor.py b/tests/components/sonarr/test_sensor.py index 43a53eeadcc..38382dc70ab 100644 --- a/tests/components/sonarr/test_sensor.py +++ b/tests/components/sonarr/test_sensor.py @@ -1,7 +1,7 @@ """The tests for the Sonarr platform.""" -import unittest -import time from datetime import datetime +import time +import unittest import pytest diff --git a/tests/components/soundtouch/test_media_player.py b/tests/components/soundtouch/test_media_player.py index f9921b5bcb2..8789db1ca1f 100644 --- a/tests/components/soundtouch/test_media_player.py +++ b/tests/components/soundtouch/test_media_player.py @@ -2,10 +2,12 @@ import logging import unittest from unittest import mock -from libsoundtouch.device import SoundTouchDevice as STD, Status, Volume, Preset, Config + +from libsoundtouch.device import Config, Preset, SoundTouchDevice as STD, Status, Volume from homeassistant.components.soundtouch import media_player as soundtouch from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING + from tests.common import get_test_home_assistant diff --git a/tests/components/spaceapi/test_init.py b/tests/components/spaceapi/test_init.py index 58c417831a9..840931d073b 100644 --- a/tests/components/spaceapi/test_init.py +++ b/tests/components/spaceapi/test_init.py @@ -3,11 +3,12 @@ from unittest.mock import patch import pytest -from tests.common import mock_coro from homeassistant.components.spaceapi import DOMAIN, SPACEAPI_VERSION, URL_API_SPACEAPI from homeassistant.setup import async_setup_component +from tests.common import mock_coro + CONFIG = { DOMAIN: { "space": "Home", diff --git a/tests/components/spc/test_init.py b/tests/components/spc/test_init.py index f726a064dd1..f08abac261f 100644 --- a/tests/components/spc/test_init.py +++ b/tests/components/spc/test_init.py @@ -1,5 +1,5 @@ """Tests for Vanderbilt SPC component.""" -from unittest.mock import patch, PropertyMock, Mock +from unittest.mock import Mock, PropertyMock, patch from homeassistant.bootstrap import async_setup_component from homeassistant.components.spc import DATA_API diff --git a/tests/components/splunk/test_init.py b/tests/components/splunk/test_init.py index 1fe4c6061cd..256c78af502 100644 --- a/tests/components/splunk/test_init.py +++ b/tests/components/splunk/test_init.py @@ -3,12 +3,12 @@ import json import unittest from unittest import mock -from homeassistant.setup import setup_component import homeassistant.components.splunk as splunk -from homeassistant.const import STATE_ON, STATE_OFF, EVENT_STATE_CHANGED -from homeassistant.helpers import state as state_helper -import homeassistant.util.dt as dt_util +from homeassistant.const import EVENT_STATE_CHANGED, STATE_OFF, STATE_ON from homeassistant.core import State +from homeassistant.helpers import state as state_helper +from homeassistant.setup import setup_component +import homeassistant.util.dt as dt_util from tests.common import get_test_home_assistant, mock_state_change_event diff --git a/tests/components/ssdp/test_init.py b/tests/components/ssdp/test_init.py index 56b937cf9d9..e224842b5ab 100644 --- a/tests/components/ssdp/test_init.py +++ b/tests/components/ssdp/test_init.py @@ -1,12 +1,12 @@ """Test the SSDP integration.""" import asyncio -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch import aiohttp import pytest -from homeassistant.generated import ssdp as gn_ssdp from homeassistant.components import ssdp +from homeassistant.generated import ssdp as gn_ssdp from tests.common import mock_coro diff --git a/tests/components/startca/test_sensor.py b/tests/components/startca/test_sensor.py index 9ecfed3ce81..ab043c44d11 100644 --- a/tests/components/startca/test_sensor.py +++ b/tests/components/startca/test_sensor.py @@ -1,5 +1,6 @@ """Tests for the Start.ca sensor platform.""" import asyncio + from homeassistant.bootstrap import async_setup_component from homeassistant.components.startca.sensor import StartcaData from homeassistant.helpers.aiohttp_client import async_get_clientsession diff --git a/tests/components/statistics/test_sensor.py b/tests/components/statistics/test_sensor.py index 2a28876f552..6a38ea6c391 100644 --- a/tests/components/statistics/test_sensor.py +++ b/tests/components/statistics/test_sensor.py @@ -1,18 +1,18 @@ """The test for the statistics sensor platform.""" -import unittest +from datetime import datetime, timedelta import statistics +import unittest +from unittest.mock import patch import pytest -from homeassistant.setup import setup_component -from homeassistant.components.statistics.sensor import StatisticsSensor -from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, STATE_UNKNOWN -from homeassistant.util import dt as dt_util -from tests.common import get_test_home_assistant -from unittest.mock import patch -from datetime import datetime, timedelta -from tests.common import init_recorder_component from homeassistant.components import recorder +from homeassistant.components.statistics.sensor import StatisticsSensor +from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, STATE_UNKNOWN, TEMP_CELSIUS +from homeassistant.setup import setup_component +from homeassistant.util import dt as dt_util + +from tests.common import get_test_home_assistant, init_recorder_component class TestStatisticsSensor(unittest.TestCase): diff --git a/tests/components/stt/test_init.py b/tests/components/stt/test_init.py index 5627d7d3e53..1e69fa2494a 100644 --- a/tests/components/stt/test_init.py +++ b/tests/components/stt/test_init.py @@ -1,7 +1,7 @@ """Test STT component setup.""" -from homeassistant.setup import async_setup_component from homeassistant.components import stt +from homeassistant.setup import async_setup_component async def test_setup_comp(hass): diff --git a/tests/components/sun/test_init.py b/tests/components/sun/test_init.py index 5346f97308f..e04de7e2578 100644 --- a/tests/components/sun/test_init.py +++ b/tests/components/sun/test_init.py @@ -5,10 +5,10 @@ from unittest.mock import patch from pytest import mark import homeassistant.components.sun as sun -import homeassistant.core as ha -import homeassistant.util.dt as dt_util from homeassistant.const import EVENT_STATE_CHANGED +import homeassistant.core as ha from homeassistant.setup import async_setup_component +import homeassistant.util.dt as dt_util async def test_setting_rising(hass): diff --git a/tests/components/switcher_kis/test_init.py b/tests/components/switcher_kis/test_init.py index ad6bafd0643..9e262fafa7e 100644 --- a/tests/components/switcher_kis/test_init.py +++ b/tests/components/switcher_kis/test_init.py @@ -1,28 +1,26 @@ """Test cases for the switcher_kis component.""" from datetime import timedelta -from typing import Any, Generator, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Generator from pytest import raises -from homeassistant.const import CONF_ENTITY_ID from homeassistant.components.switcher_kis import ( CONF_AUTO_OFF, - DOMAIN, DATA_DEVICE, + DOMAIN, SERVICE_SET_AUTO_OFF_NAME, SERVICE_SET_AUTO_OFF_SCHEMA, SIGNAL_SWITCHER_DEVICE_UPDATE, ) -from homeassistant.core import callback, Context +from homeassistant.const import CONF_ENTITY_ID +from homeassistant.core import Context, callback +from homeassistant.exceptions import Unauthorized, UnknownUser from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.typing import HomeAssistantType -from homeassistant.exceptions import Unauthorized, UnknownUser from homeassistant.setup import async_setup_component from homeassistant.util import dt -from tests.common import async_mock_service, async_fire_time_changed - from .consts import ( DUMMY_AUTO_OFF_SET, DUMMY_DEVICE_ID, @@ -38,6 +36,8 @@ from .consts import ( SWITCH_ENTITY_ID, ) +from tests.common import async_fire_time_changed, async_mock_service + if TYPE_CHECKING: from tests.common import MockUser from aioswitcher.devices import SwitcherV2Device diff --git a/tests/components/system_log/test_init.py b/tests/components/system_log/test_init.py index 55d69db8fb4..c21d4842b45 100644 --- a/tests/components/system_log/test_init.py +++ b/tests/components/system_log/test_init.py @@ -2,9 +2,9 @@ import logging from unittest.mock import MagicMock, patch -from homeassistant.core import callback from homeassistant.bootstrap import async_setup_component from homeassistant.components import system_log +from homeassistant.core import callback _LOGGER = logging.getLogger("test_logger") BASIC_CONFIG = {"system_log": {"max_entries": 2}}