From b68a2747f31efa37f992e62e0a59a2856dc1a329 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Mon, 13 Dec 2021 20:03:01 +0100 Subject: [PATCH] Use relative imports [A-H] (#61574) --- .../alarm_control_panel/device_condition.py | 12 +++++------- .../alarm_control_panel/device_trigger.py | 12 ++++++------ .../components/august/binary_sensor.py | 2 +- homeassistant/components/august/sensor.py | 2 +- homeassistant/components/awair/sensor.py | 2 +- .../components/azure_devops/config_flow.py | 8 ++------ .../components/azure_devops/sensor.py | 8 +++----- homeassistant/components/blink/config_flow.py | 7 ++----- .../components/cover/reproduce_state.py | 14 +++++++------- homeassistant/components/deconz/config_flow.py | 3 +-- homeassistant/components/deconz/services.py | 2 +- .../device_automation/toggle_entity.py | 18 +++++++++--------- .../components/device_automation/trigger.py | 5 +---- .../components/dynalite/dynalitebase.py | 2 +- homeassistant/components/efergy/sensor.py | 2 +- homeassistant/components/elmax/common.py | 3 ++- homeassistant/components/elmax/config_flow.py | 7 ++++--- homeassistant/components/elmax/switch.py | 7 ++++--- .../components/geo_location/trigger.py | 3 ++- .../components/google_travel_time/helpers.py | 3 ++- .../components/honeywell/config_flow.py | 2 +- 21 files changed, 57 insertions(+), 67 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/device_condition.py b/homeassistant/components/alarm_control_panel/device_condition.py index cc01f4a5954..a378cf262ed 100644 --- a/homeassistant/components/alarm_control_panel/device_condition.py +++ b/homeassistant/components/alarm_control_panel/device_condition.py @@ -5,13 +5,6 @@ from typing import Final import voluptuous as vol -from homeassistant.components.alarm_control_panel.const import ( - SUPPORT_ALARM_ARM_AWAY, - SUPPORT_ALARM_ARM_CUSTOM_BYPASS, - SUPPORT_ALARM_ARM_HOME, - SUPPORT_ALARM_ARM_NIGHT, - SUPPORT_ALARM_ARM_VACATION, -) from homeassistant.const import ( ATTR_ENTITY_ID, CONF_CONDITION, @@ -42,6 +35,11 @@ from .const import ( CONDITION_ARMED_VACATION, CONDITION_DISARMED, CONDITION_TRIGGERED, + SUPPORT_ALARM_ARM_AWAY, + SUPPORT_ALARM_ARM_CUSTOM_BYPASS, + SUPPORT_ALARM_ARM_HOME, + SUPPORT_ALARM_ARM_NIGHT, + SUPPORT_ALARM_ARM_VACATION, ) CONDITION_TYPES: Final[set[str]] = { diff --git a/homeassistant/components/alarm_control_panel/device_trigger.py b/homeassistant/components/alarm_control_panel/device_trigger.py index 9eea745862a..ce53596fc8d 100644 --- a/homeassistant/components/alarm_control_panel/device_trigger.py +++ b/homeassistant/components/alarm_control_panel/device_trigger.py @@ -5,12 +5,6 @@ from typing import Any, Final import voluptuous as vol -from homeassistant.components.alarm_control_panel.const import ( - SUPPORT_ALARM_ARM_AWAY, - SUPPORT_ALARM_ARM_HOME, - SUPPORT_ALARM_ARM_NIGHT, - SUPPORT_ALARM_ARM_VACATION, -) from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, @@ -38,6 +32,12 @@ from homeassistant.helpers.entity import get_supported_features from homeassistant.helpers.typing import ConfigType from . import DOMAIN +from .const import ( + SUPPORT_ALARM_ARM_AWAY, + SUPPORT_ALARM_ARM_HOME, + SUPPORT_ALARM_ARM_NIGHT, + SUPPORT_ALARM_ARM_VACATION, +) BASIC_TRIGGER_TYPES: Final[set[str]] = {"triggered", "disarmed", "arming"} TRIGGER_TYPES: Final[set[str]] = BASIC_TRIGGER_TYPES | { diff --git a/homeassistant/components/august/binary_sensor.py b/homeassistant/components/august/binary_sensor.py index d8c2117f4a3..2ec53b06bdb 100644 --- a/homeassistant/components/august/binary_sensor.py +++ b/homeassistant/components/august/binary_sensor.py @@ -17,7 +17,6 @@ from yalexs.doorbell import DoorbellDetail from yalexs.lock import LockDoorStatus from yalexs.util import update_lock_detail_from_activity -from homeassistant.components.august import AugustData from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, BinarySensorEntity, @@ -27,6 +26,7 @@ from homeassistant.core import callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.event import async_call_later +from . import AugustData from .const import ACTIVITY_UPDATE_INTERVAL, DATA_AUGUST, DOMAIN from .entity import AugustEntityMixin diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 031e6fd9282..a7b28070f8e 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -10,7 +10,6 @@ from yalexs.activity import ActivityType from yalexs.keypad import KeypadDetail from yalexs.lock import LockDetail -from homeassistant.components.august import AugustData from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, @@ -22,6 +21,7 @@ from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.helpers.restore_state import RestoreEntity +from . import AugustData from .const import ( ATTR_OPERATION_AUTORELOCK, ATTR_OPERATION_KEYPAD, diff --git a/homeassistant/components/awair/sensor.py b/homeassistant/components/awair/sensor.py index 4e67e56cfe3..b74c19330ed 100644 --- a/homeassistant/components/awair/sensor.py +++ b/homeassistant/components/awair/sensor.py @@ -5,7 +5,6 @@ from python_awair.air_data import AirData from python_awair.devices import AwairDevice import voluptuous as vol -from homeassistant.components.awair import AwairDataUpdateCoordinator, AwairResult from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( @@ -21,6 +20,7 @@ from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity +from . import AwairDataUpdateCoordinator, AwairResult from .const import ( API_DUST, API_PM25, diff --git a/homeassistant/components/azure_devops/config_flow.py b/homeassistant/components/azure_devops/config_flow.py index 30073031195..350bad5852a 100644 --- a/homeassistant/components/azure_devops/config_flow.py +++ b/homeassistant/components/azure_devops/config_flow.py @@ -3,14 +3,10 @@ from aioazuredevops.client import DevOpsClient import aiohttp import voluptuous as vol -from homeassistant.components.azure_devops.const import ( - CONF_ORG, - CONF_PAT, - CONF_PROJECT, - DOMAIN, -) from homeassistant.config_entries import ConfigFlow +from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN + class AzureDevOpsFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a Azure DevOps config flow.""" diff --git a/homeassistant/components/azure_devops/sensor.py b/homeassistant/components/azure_devops/sensor.py index d249e8a8088..ac884f73d68 100644 --- a/homeassistant/components/azure_devops/sensor.py +++ b/homeassistant/components/azure_devops/sensor.py @@ -7,17 +7,15 @@ from typing import Any from aioazuredevops.builds import DevOpsBuild -from homeassistant.components.azure_devops import ( - AzureDevOpsDeviceEntity, - AzureDevOpsEntityDescription, -) -from homeassistant.components.azure_devops.const import CONF_ORG, DOMAIN from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType +from . import AzureDevOpsDeviceEntity, AzureDevOpsEntityDescription +from .const import CONF_ORG, DOMAIN + @dataclass class AzureDevOpsSensorEntityDescriptionMixin: diff --git a/homeassistant/components/blink/config_flow.py b/homeassistant/components/blink/config_flow.py index b46243a12d9..a4bee490fb3 100644 --- a/homeassistant/components/blink/config_flow.py +++ b/homeassistant/components/blink/config_flow.py @@ -6,11 +6,6 @@ from blinkpy.blinkpy import Blink, BlinkSetupError import voluptuous as vol from homeassistant import config_entries, core, exceptions -from homeassistant.components.blink.const import ( - DEFAULT_SCAN_INTERVAL, - DEVICE_ID, - DOMAIN, -) from homeassistant.const import ( CONF_PASSWORD, CONF_PIN, @@ -19,6 +14,8 @@ from homeassistant.const import ( ) from homeassistant.core import callback +from .const import DEFAULT_SCAN_INTERVAL, DEVICE_ID, DOMAIN + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/cover/reproduce_state.py b/homeassistant/components/cover/reproduce_state.py index 1be68bcfeba..59846627890 100644 --- a/homeassistant/components/cover/reproduce_state.py +++ b/homeassistant/components/cover/reproduce_state.py @@ -6,12 +6,6 @@ from collections.abc import Iterable import logging from typing import Any -from homeassistant.components.cover import ( - ATTR_CURRENT_POSITION, - ATTR_CURRENT_TILT_POSITION, - ATTR_POSITION, - ATTR_TILT_POSITION, -) from homeassistant.const import ( ATTR_ENTITY_ID, SERVICE_CLOSE_COVER, @@ -27,7 +21,13 @@ from homeassistant.const import ( ) from homeassistant.core import Context, HomeAssistant, State -from . import DOMAIN +from . import ( + ATTR_CURRENT_POSITION, + ATTR_CURRENT_TILT_POSITION, + ATTR_POSITION, + ATTR_TILT_POSITION, + DOMAIN, +) _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py index 473cbd72971..e4d61394ce0 100644 --- a/homeassistant/components/deconz/config_flow.py +++ b/homeassistant/components/deconz/config_flow.py @@ -19,7 +19,6 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.components import ssdp -from homeassistant.components.deconz.gateway import DeconzGateway from homeassistant.components.hassio import HassioServiceInfo from homeassistant.config_entries import ConfigEntry, ConfigFlow, OptionsFlow from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT @@ -36,7 +35,7 @@ from .const import ( DOMAIN, LOGGER, ) -from .gateway import get_gateway_from_config_entry +from .gateway import DeconzGateway, get_gateway_from_config_entry DECONZ_MANUFACTURERURL = "http://www.dresden-elektronik.de" CONF_SERIAL = "serial" diff --git a/homeassistant/components/deconz/services.py b/homeassistant/components/deconz/services.py index 529616138a2..aeb528c0ac9 100644 --- a/homeassistant/components/deconz/services.py +++ b/homeassistant/components/deconz/services.py @@ -5,7 +5,6 @@ from types import MappingProxyType from pydeconz.utils import normalize_bridge_id import voluptuous as vol -from homeassistant.components.deconz.gateway import DeconzGateway from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import ( config_validation as cv, @@ -20,6 +19,7 @@ from homeassistant.helpers.entity_registry import ( from .config_flow import get_master_gateway from .const import CONF_BRIDGE_ID, DOMAIN, LOGGER +from .gateway import DeconzGateway DECONZ_SERVICES = "deconz_services" diff --git a/homeassistant/components/device_automation/toggle_entity.py b/homeassistant/components/device_automation/toggle_entity.py index 2d0254b9a0a..8128eca9dbc 100644 --- a/homeassistant/components/device_automation/toggle_entity.py +++ b/homeassistant/components/device_automation/toggle_entity.py @@ -9,15 +9,6 @@ from homeassistant.components.automation import ( AutomationActionType, AutomationTriggerInfo, ) -from homeassistant.components.device_automation.const import ( - CONF_IS_OFF, - CONF_IS_ON, - CONF_TOGGLE, - CONF_TURN_OFF, - CONF_TURN_ON, - CONF_TURNED_OFF, - CONF_TURNED_ON, -) from homeassistant.components.homeassistant.triggers import state as state_trigger from homeassistant.const import ( ATTR_ENTITY_ID, @@ -33,6 +24,15 @@ from homeassistant.helpers.entity_registry import async_entries_for_device from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import DEVICE_TRIGGER_BASE_SCHEMA +from .const import ( + CONF_IS_OFF, + CONF_IS_ON, + CONF_TOGGLE, + CONF_TURN_OFF, + CONF_TURN_ON, + CONF_TURNED_OFF, + CONF_TURNED_ON, +) # mypy: allow-untyped-calls, allow-untyped-defs diff --git a/homeassistant/components/device_automation/trigger.py b/homeassistant/components/device_automation/trigger.py index 1a63dcb9e9b..62bd8d1c808 100644 --- a/homeassistant/components/device_automation/trigger.py +++ b/homeassistant/components/device_automation/trigger.py @@ -1,12 +1,9 @@ """Offer device oriented automation.""" import voluptuous as vol -from homeassistant.components.device_automation import ( - DEVICE_TRIGGER_BASE_SCHEMA, - async_get_device_automation_platform, -) from homeassistant.const import CONF_DOMAIN +from . import DEVICE_TRIGGER_BASE_SCHEMA, async_get_device_automation_platform from .exceptions import InvalidDeviceAutomationConfig # mypy: allow-untyped-defs, no-check-untyped-defs diff --git a/homeassistant/components/dynalite/dynalitebase.py b/homeassistant/components/dynalite/dynalitebase.py index 9bb4f3aeb27..c1814307d1c 100644 --- a/homeassistant/components/dynalite/dynalitebase.py +++ b/homeassistant/components/dynalite/dynalitebase.py @@ -4,13 +4,13 @@ from __future__ import annotations from collections.abc import Callable from typing import Any -from homeassistant.components.dynalite.bridge import DynaliteBridge from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .bridge import DynaliteBridge from .const import DOMAIN, LOGGER diff --git a/homeassistant/components/efergy/sensor.py b/homeassistant/components/efergy/sensor.py index e2d71716f24..b448c6db6ec 100644 --- a/homeassistant/components/efergy/sensor.py +++ b/homeassistant/components/efergy/sensor.py @@ -7,7 +7,6 @@ from re import sub from pyefergy import Efergy, exceptions import voluptuous as vol -from homeassistant.components.efergy import EfergyEntity from homeassistant.components.sensor import ( PLATFORM_SCHEMA, SensorDeviceClass, @@ -29,6 +28,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from . import EfergyEntity from .const import CONF_APPTOKEN, CONF_CURRENT_VALUES, DATA_KEY_API, DOMAIN _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/elmax/common.py b/homeassistant/components/elmax/common.py index b44ffa2152b..43d1cbff150 100644 --- a/homeassistant/components/elmax/common.py +++ b/homeassistant/components/elmax/common.py @@ -18,12 +18,13 @@ from elmax_api.http import Elmax from elmax_api.model.endpoint import DeviceEndpoint from elmax_api.model.panel import PanelEntry, PanelStatus -from homeassistant.components.elmax.const import DEFAULT_TIMEOUT, DOMAIN from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator +from .const import DEFAULT_TIMEOUT, DOMAIN + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/elmax/config_flow.py b/homeassistant/components/elmax/config_flow.py index c19c49f4b0b..5cd2169c695 100644 --- a/homeassistant/components/elmax/config_flow.py +++ b/homeassistant/components/elmax/config_flow.py @@ -10,7 +10,10 @@ from elmax_api.model.panel import PanelEntry import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.elmax.const import ( +from homeassistant.data_entry_flow import FlowResult +from homeassistant.exceptions import HomeAssistantError + +from .const import ( CONF_ELMAX_PANEL_ID, CONF_ELMAX_PANEL_NAME, CONF_ELMAX_PANEL_PIN, @@ -18,8 +21,6 @@ from homeassistant.components.elmax.const import ( CONF_ELMAX_USERNAME, DOMAIN, ) -from homeassistant.data_entry_flow import FlowResult -from homeassistant.exceptions import HomeAssistantError _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/elmax/switch.py b/homeassistant/components/elmax/switch.py index 4a8cd5f4214..11c0c406576 100644 --- a/homeassistant/components/elmax/switch.py +++ b/homeassistant/components/elmax/switch.py @@ -4,14 +4,15 @@ from typing import Any from elmax_api.model.command import SwitchCommand from elmax_api.model.panel import PanelStatus -from homeassistant.components.elmax import ElmaxCoordinator -from homeassistant.components.elmax.common import ElmaxEntity -from homeassistant.components.elmax.const import DOMAIN from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import HomeAssistantType +from . import ElmaxCoordinator +from .common import ElmaxEntity +from .const import DOMAIN + class ElmaxSwitch(ElmaxEntity, SwitchEntity): """Implement the Elmax switch entity.""" diff --git a/homeassistant/components/geo_location/trigger.py b/homeassistant/components/geo_location/trigger.py index c030b3d3075..e57c7a9aec6 100644 --- a/homeassistant/components/geo_location/trigger.py +++ b/homeassistant/components/geo_location/trigger.py @@ -3,13 +3,14 @@ import logging import voluptuous as vol -from homeassistant.components.geo_location import DOMAIN from homeassistant.const import CONF_EVENT, CONF_PLATFORM, CONF_SOURCE, CONF_ZONE from homeassistant.core import HassJob, callback from homeassistant.helpers import condition, config_validation as cv from homeassistant.helpers.config_validation import entity_domain from homeassistant.helpers.event import TrackStates, async_track_state_change_filtered +from . import DOMAIN + # mypy: allow-untyped-defs, no-check-untyped-defs _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/google_travel_time/helpers.py b/homeassistant/components/google_travel_time/helpers.py index 00d3119e868..f295bceb65d 100644 --- a/homeassistant/components/google_travel_time/helpers.py +++ b/homeassistant/components/google_travel_time/helpers.py @@ -3,10 +3,11 @@ from googlemaps import Client from googlemaps.distance_matrix import distance_matrix from googlemaps.exceptions import ApiError -from homeassistant.components.google_travel_time.const import TRACKABLE_DOMAINS from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE from homeassistant.helpers import location +from .const import TRACKABLE_DOMAINS + def is_valid_config_entry(hass, logger, api_key, origin, destination): """Return whether the config entry data is valid.""" diff --git a/homeassistant/components/honeywell/config_flow.py b/homeassistant/components/honeywell/config_flow.py index 318809aaa03..ecf42f4533f 100644 --- a/homeassistant/components/honeywell/config_flow.py +++ b/homeassistant/components/honeywell/config_flow.py @@ -2,9 +2,9 @@ import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.honeywell import get_somecomfort_client from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from . import get_somecomfort_client from .const import CONF_COOL_AWAY_TEMPERATURE, CONF_HEAT_AWAY_TEMPERATURE, DOMAIN