From b731ddabde71b54fe295e76c26896b884b71ea9e Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sun, 8 Dec 2019 18:16:49 +0100 Subject: [PATCH] Sort imports according to PEP8 for homekit (#29645) --- homeassistant/components/homekit/__init__.py | 3 +-- .../components/homekit/type_media_players.py | 20 +++++++++---------- .../components/homekit/type_thermostats.py | 4 ++-- tests/components/homekit/conftest.py | 3 +-- tests/components/homekit/test_accessories.py | 8 ++++---- .../homekit/test_get_accessories.py | 10 +++++----- tests/components/homekit/test_homekit.py | 14 ++++++------- tests/components/homekit/test_type_lights.py | 4 ++-- .../homekit/test_type_media_players.py | 2 +- tests/components/homekit/test_type_sensors.py | 4 ++-- .../homekit/test_type_thermostats.py | 4 ++-- 11 files changed, 36 insertions(+), 40 deletions(-) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 525c091e177..cfd59ad61a4 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -45,8 +45,8 @@ from .const import ( DEVICE_CLASS_PM25, DOMAIN, HOMEKIT_FILE, - SERVICE_HOMEKIT_START, SERVICE_HOMEKIT_RESET_ACCESSORY, + SERVICE_HOMEKIT_START, TYPE_FAUCET, TYPE_OUTLET, TYPE_SHOWER, @@ -54,7 +54,6 @@ from .const import ( TYPE_SWITCH, TYPE_VALVE, ) - from .util import ( show_setup_message, validate_entity_config, diff --git a/homeassistant/components/homekit/type_media_players.py b/homeassistant/components/homekit/type_media_players.py index d9b24782610..450ae818ec8 100644 --- a/homeassistant/components/homekit/type_media_players.py +++ b/homeassistant/components/homekit/type_media_players.py @@ -6,16 +6,16 @@ from pyhap.const import CATEGORY_SWITCH, CATEGORY_TELEVISION from homeassistant.components.media_player import ( ATTR_INPUT_SOURCE, ATTR_INPUT_SOURCE_LIST, - ATTR_MEDIA_VOLUME_MUTED, ATTR_MEDIA_VOLUME_LEVEL, - SERVICE_SELECT_SOURCE, + ATTR_MEDIA_VOLUME_MUTED, DOMAIN, + SERVICE_SELECT_SOURCE, SUPPORT_PAUSE, SUPPORT_PLAY, + SUPPORT_SELECT_SOURCE, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP, - SUPPORT_SELECT_SOURCE, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -26,13 +26,13 @@ from homeassistant.const import ( SERVICE_MEDIA_STOP, SERVICE_TURN_OFF, SERVICE_TURN_ON, - SERVICE_VOLUME_MUTE, - SERVICE_VOLUME_UP, SERVICE_VOLUME_DOWN, + SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, + SERVICE_VOLUME_UP, STATE_OFF, - STATE_PLAYING, STATE_PAUSED, + STATE_PLAYING, STATE_UNKNOWN, ) @@ -46,23 +46,23 @@ from .const import ( CHAR_IDENTIFIER, CHAR_INPUT_SOURCE_TYPE, CHAR_IS_CONFIGURED, - CHAR_NAME, - CHAR_SLEEP_DISCOVER_MODE, CHAR_MUTE, + CHAR_NAME, CHAR_ON, CHAR_REMOTE_KEY, + CHAR_SLEEP_DISCOVER_MODE, + CHAR_VOLUME, CHAR_VOLUME_CONTROL_TYPE, CHAR_VOLUME_SELECTOR, - CHAR_VOLUME, CONF_FEATURE_LIST, FEATURE_ON_OFF, FEATURE_PLAY_PAUSE, FEATURE_PLAY_STOP, FEATURE_TOGGLE_MUTE, + SERV_INPUT_SOURCE, SERV_SWITCH, SERV_TELEVISION, SERV_TELEVISION_SPEAKER, - SERV_INPUT_SOURCE, ) _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index b6e1e75d3c6..79a9d156f10 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -20,12 +20,12 @@ from homeassistant.components.climate.const import ( DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN as DOMAIN_CLIMATE, + HVAC_MODE_AUTO, HVAC_MODE_COOL, + HVAC_MODE_FAN_ONLY, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, - HVAC_MODE_AUTO, - HVAC_MODE_FAN_ONLY, SERVICE_SET_HVAC_MODE as SERVICE_SET_HVAC_MODE_THERMOSTAT, SERVICE_SET_TEMPERATURE as SERVICE_SET_TEMPERATURE_THERMOSTAT, SUPPORT_TARGET_TEMPERATURE_RANGE, diff --git a/tests/components/homekit/conftest.py b/tests/components/homekit/conftest.py index c7e749fbad9..ef534d0e472 100644 --- a/tests/components/homekit/conftest.py +++ b/tests/components/homekit/conftest.py @@ -1,13 +1,12 @@ """HomeKit session fixtures.""" from unittest.mock import patch +from pyhap.accessory_driver import AccessoryDriver import pytest from homeassistant.components.homekit.const import EVENT_HOMEKIT_CHANGED from homeassistant.core import callback as ha_callback -from pyhap.accessory_driver import AccessoryDriver - @pytest.fixture(scope="session") def hk_driver(): diff --git a/tests/components/homekit/test_accessories.py b/tests/components/homekit/test_accessories.py index 883d84339e5..0c5810a5b10 100644 --- a/tests/components/homekit/test_accessories.py +++ b/tests/components/homekit/test_accessories.py @@ -3,15 +3,15 @@ This includes tests for all mock object types. """ from datetime import datetime, timedelta -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch import pytest from homeassistant.components.homekit.accessories import ( - debounce, HomeAccessory, HomeBridge, HomeDriver, + debounce, ) from homeassistant.components.homekit.const import ( ATTR_DISPLAY_NAME, @@ -30,13 +30,13 @@ from homeassistant.components.homekit.const import ( SERV_ACCESSORY_INFO, ) from homeassistant.const import ( - __version__, ATTR_BATTERY_CHARGING, ATTR_BATTERY_LEVEL, ATTR_ENTITY_ID, - ATTR_SERVICE, ATTR_NOW, + ATTR_SERVICE, EVENT_TIME_CHANGED, + __version__, ) import homeassistant.util.dt as dt_util diff --git a/tests/components/homekit/test_get_accessories.py b/tests/components/homekit/test_get_accessories.py index eb15b461461..e6bf185c93b 100644 --- a/tests/components/homekit/test_get_accessories.py +++ b/tests/components/homekit/test_get_accessories.py @@ -1,13 +1,11 @@ """Package to test the get_accessory method.""" -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch import pytest -from homeassistant.core import State -import homeassistant.components.cover as cover import homeassistant.components.climate as climate -import homeassistant.components.media_player.const as media_player_c -from homeassistant.components.homekit import get_accessory, TYPES +import homeassistant.components.cover as cover +from homeassistant.components.homekit import TYPES, get_accessory from homeassistant.components.homekit.const import ( CONF_FEATURE_LIST, FEATURE_ON_OFF, @@ -18,6 +16,7 @@ from homeassistant.components.homekit.const import ( TYPE_SWITCH, TYPE_VALVE, ) +import homeassistant.components.media_player.const as media_player_c from homeassistant.const import ( ATTR_CODE, ATTR_DEVICE_CLASS, @@ -28,6 +27,7 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, ) +from homeassistant.core import State def test_not_supported(caplog): diff --git a/tests/components/homekit/test_homekit.py b/tests/components/homekit/test_homekit.py index 97838eaa852..de6aaf0f11e 100644 --- a/tests/components/homekit/test_homekit.py +++ b/tests/components/homekit/test_homekit.py @@ -1,35 +1,34 @@ """Tests for the HomeKit component.""" -from unittest.mock import patch, ANY, Mock +from unittest.mock import ANY, Mock, patch import pytest from homeassistant import setup - from homeassistant.components.homekit import ( - generate_aid, - HomeKit, MAX_DEVICES, STATUS_READY, STATUS_RUNNING, STATUS_STOPPED, STATUS_WAIT, + HomeKit, + generate_aid, ) from homeassistant.components.homekit.accessories import HomeBridge from homeassistant.components.homekit.const import ( + BRIDGE_NAME, CONF_AUTO_START, CONF_SAFE_MODE, - BRIDGE_NAME, DEFAULT_PORT, DEFAULT_SAFE_MODE, DOMAIN, HOMEKIT_FILE, - SERVICE_HOMEKIT_START, SERVICE_HOMEKIT_RESET_ACCESSORY, + SERVICE_HOMEKIT_START, ) from homeassistant.const import ( ATTR_ENTITY_ID, - CONF_NAME, CONF_IP_ADDRESS, + CONF_NAME, CONF_PORT, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, @@ -39,7 +38,6 @@ from homeassistant.helpers.entityfilter import generate_filter from tests.components.homekit.common import patch_debounce - IP_ADDRESS = "127.0.0.1" PATH_HOMEKIT = "homeassistant.components.homekit" diff --git a/tests/components/homekit/test_type_lights.py b/tests/components/homekit/test_type_lights.py index 784a6c82346..3444b2778f6 100644 --- a/tests/components/homekit/test_type_lights.py +++ b/tests/components/homekit/test_type_lights.py @@ -11,14 +11,14 @@ from homeassistant.components.light import ( ATTR_HS_COLOR, DOMAIN, SUPPORT_BRIGHTNESS, - SUPPORT_COLOR_TEMP, SUPPORT_COLOR, + SUPPORT_COLOR_TEMP, ) from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, - STATE_ON, STATE_OFF, + STATE_ON, STATE_UNKNOWN, ) diff --git a/tests/components/homekit/test_type_media_players.py b/tests/components/homekit/test_type_media_players.py index f2682fc86b0..aa007b4d04c 100644 --- a/tests/components/homekit/test_type_media_players.py +++ b/tests/components/homekit/test_type_media_players.py @@ -8,11 +8,11 @@ from homeassistant.components.homekit.const import ( FEATURE_PLAY_STOP, FEATURE_TOGGLE_MUTE, ) -from homeassistant.components.media_player import DEVICE_CLASS_TV from homeassistant.components.homekit.type_media_players import ( MediaPlayer, TelevisionMediaPlayer, ) +from homeassistant.components.media_player import DEVICE_CLASS_TV from homeassistant.components.media_player.const import ( ATTR_INPUT_SOURCE, ATTR_INPUT_SOURCE_LIST, diff --git a/tests/components/homekit/test_type_sensors.py b/tests/components/homekit/test_type_sensors.py index c2ed4873286..43533840cc6 100644 --- a/tests/components/homekit/test_type_sensors.py +++ b/tests/components/homekit/test_type_sensors.py @@ -5,14 +5,14 @@ from homeassistant.components.homekit.const import ( THRESHOLD_CO2, ) from homeassistant.components.homekit.type_sensors import ( + BINARY_SENSOR_SERVICE_MAP, AirQualitySensor, BinarySensor, - CarbonMonoxideSensor, CarbonDioxideSensor, + CarbonMonoxideSensor, HumiditySensor, LightSensor, TemperatureSensor, - BINARY_SENSOR_SERVICE_MAP, ) from homeassistant.const import ( ATTR_DEVICE_CLASS, diff --git a/tests/components/homekit/test_type_thermostats.py b/tests/components/homekit/test_type_thermostats.py index 9f9ebcdfd32..174b72f780a 100644 --- a/tests/components/homekit/test_type_thermostats.py +++ b/tests/components/homekit/test_type_thermostats.py @@ -20,12 +20,12 @@ from homeassistant.components.climate.const import ( DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN as DOMAIN_CLIMATE, + HVAC_MODE_AUTO, HVAC_MODE_COOL, + HVAC_MODE_FAN_ONLY, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, - HVAC_MODE_FAN_ONLY, - HVAC_MODE_AUTO, ) from homeassistant.components.homekit.const import ( ATTR_VALUE,