From 83989d7b40521bf53a188cfdbe010bf2fe37e08a Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Mon, 13 Dec 2021 00:24:46 +0100 Subject: [PATCH] Use relative imports [L-R] (#61575) --- .../components/light/device_action.py | 12 +++++------ .../components/media_source/local_source.py | 2 +- .../components/metoffice/config_flow.py | 2 +- .../components/mysensors/binary_sensor.py | 3 +-- homeassistant/components/mysensors/climate.py | 2 +- .../components/mysensors/config_flow.py | 16 +++++++------- homeassistant/components/mysensors/cover.py | 2 +- .../components/mysensors/device_tracker.py | 8 ++----- homeassistant/components/neato/camera.py | 2 +- homeassistant/components/neato/sensor.py | 2 +- homeassistant/components/neato/switch.py | 2 +- .../components/nexia/binary_sensor.py | 2 +- .../components/nsw_fuel_station/sensor.py | 6 ++---- homeassistant/components/nut/sensor.py | 2 +- .../components/onewire/binary_sensor.py | 2 +- homeassistant/components/onewire/sensor.py | 5 +---- homeassistant/components/onewire/switch.py | 2 +- homeassistant/components/opengarage/entity.py | 3 ++- .../components/opnsense/device_tracker.py | 3 ++- .../components/pi_hole/config_flow.py | 21 ++++++++++--------- .../components/pilight/base_class.py | 2 +- homeassistant/components/ps4/media_player.py | 2 +- homeassistant/components/recorder/history.py | 8 ++----- .../components/rfxtrx/device_trigger.py | 2 +- 24 files changed, 51 insertions(+), 62 deletions(-) diff --git a/homeassistant/components/light/device_action.py b/homeassistant/components/light/device_action.py index a933d04066e..3d9f2790766 100644 --- a/homeassistant/components/light/device_action.py +++ b/homeassistant/components/light/device_action.py @@ -4,13 +4,6 @@ from __future__ import annotations import voluptuous as vol from homeassistant.components.device_automation import toggle_entity -from homeassistant.components.light import ( - ATTR_FLASH, - FLASH_SHORT, - SUPPORT_FLASH, - VALID_BRIGHTNESS_PCT, - VALID_FLASH, -) from homeassistant.const import ( ATTR_ENTITY_ID, CONF_DEVICE_ID, @@ -27,7 +20,12 @@ from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import ( ATTR_BRIGHTNESS_PCT, ATTR_BRIGHTNESS_STEP_PCT, + ATTR_FLASH, DOMAIN, + FLASH_SHORT, + SUPPORT_FLASH, + VALID_BRIGHTNESS_PCT, + VALID_FLASH, brightness_supported, get_supported_color_modes, ) diff --git a/homeassistant/components/media_source/local_source.py b/homeassistant/components/media_source/local_source.py index c7b25b4400c..ab2cc531e1e 100644 --- a/homeassistant/components/media_source/local_source.py +++ b/homeassistant/components/media_source/local_source.py @@ -9,11 +9,11 @@ from aiohttp import web from homeassistant.components.http import HomeAssistantView from homeassistant.components.media_player.const import MEDIA_CLASS_DIRECTORY from homeassistant.components.media_player.errors import BrowseError -from homeassistant.components.media_source.error import Unresolvable from homeassistant.core import HomeAssistant, callback from homeassistant.util import raise_if_invalid_path from .const import DOMAIN, MEDIA_CLASS_MAP, MEDIA_MIME_TYPES +from .error import Unresolvable from .models import BrowseMediaSource, MediaSource, MediaSourceItem, PlayMedia diff --git a/homeassistant/components/metoffice/config_flow.py b/homeassistant/components/metoffice/config_flow.py index 375eaa1ec1b..959680a90ec 100644 --- a/homeassistant/components/metoffice/config_flow.py +++ b/homeassistant/components/metoffice/config_flow.py @@ -5,11 +5,11 @@ import datapoint import voluptuous as vol from homeassistant import config_entries, core, exceptions -from homeassistant.components.metoffice.helpers import fetch_site from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.helpers import config_validation as cv from .const import DOMAIN +from .helpers import fetch_site _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/mysensors/binary_sensor.py b/homeassistant/components/mysensors/binary_sensor.py index f94b5f71728..91dc454dae3 100644 --- a/homeassistant/components/mysensors/binary_sensor.py +++ b/homeassistant/components/mysensors/binary_sensor.py @@ -12,14 +12,13 @@ from homeassistant.components.binary_sensor import ( DOMAIN, BinarySensorEntity, ) -from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY from homeassistant.config_entries import ConfigEntry from homeassistant.const import STATE_ON from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback -from .const import DiscoveryInfo +from .const import MYSENSORS_DISCOVERY, DiscoveryInfo from .helpers import on_unload SENSORS = { diff --git a/homeassistant/components/mysensors/climate.py b/homeassistant/components/mysensors/climate.py index 5dd52673581..4a12b872bdc 100644 --- a/homeassistant/components/mysensors/climate.py +++ b/homeassistant/components/mysensors/climate.py @@ -17,13 +17,13 @@ from homeassistant.components.climate.const import ( SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE, ) -from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY, DiscoveryInfo from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .const import MYSENSORS_DISCOVERY, DiscoveryInfo from .helpers import on_unload DICT_HA_TO_MYS = { diff --git a/homeassistant/components/mysensors/config_flow.py b/homeassistant/components/mysensors/config_flow.py index aea15e7b8ae..5c190d6fd56 100644 --- a/homeassistant/components/mysensors/config_flow.py +++ b/homeassistant/components/mysensors/config_flow.py @@ -17,18 +17,20 @@ from homeassistant.components.mqtt import ( valid_publish_topic, valid_subscribe_topic, ) -from homeassistant.components.mysensors import ( - CONF_DEVICE, - DEFAULT_BAUD_RATE, - DEFAULT_TCP_PORT, - is_persistence_file, -) from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult import homeassistant.helpers.config_validation as cv -from . import CONF_RETAIN, CONF_VERSION, DEFAULT_VERSION +from . import ( + CONF_DEVICE, + CONF_RETAIN, + CONF_VERSION, + DEFAULT_BAUD_RATE, + DEFAULT_TCP_PORT, + DEFAULT_VERSION, + is_persistence_file, +) from .const import ( CONF_BAUD_RATE, CONF_GATEWAY_TYPE, diff --git a/homeassistant/components/mysensors/cover.py b/homeassistant/components/mysensors/cover.py index 9219097bea4..102f7ccaca8 100644 --- a/homeassistant/components/mysensors/cover.py +++ b/homeassistant/components/mysensors/cover.py @@ -6,13 +6,13 @@ from typing import Any from homeassistant.components import mysensors from homeassistant.components.cover import ATTR_POSITION, DOMAIN, CoverEntity -from homeassistant.components.mysensors.const import MYSENSORS_DISCOVERY, DiscoveryInfo from homeassistant.config_entries import ConfigEntry from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .const import MYSENSORS_DISCOVERY, DiscoveryInfo from .helpers import on_unload diff --git a/homeassistant/components/mysensors/device_tracker.py b/homeassistant/components/mysensors/device_tracker.py index 1dd29dbf864..bfb4649e7cd 100644 --- a/homeassistant/components/mysensors/device_tracker.py +++ b/homeassistant/components/mysensors/device_tracker.py @@ -6,16 +6,12 @@ from typing import Any from homeassistant.components import mysensors from homeassistant.components.device_tracker import DOMAIN -from homeassistant.components.mysensors import DevId -from homeassistant.components.mysensors.const import ( - ATTR_GATEWAY_ID, - DiscoveryInfo, - GatewayId, -) from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.util import slugify +from . import DevId +from .const import ATTR_GATEWAY_ID, DiscoveryInfo, GatewayId from .helpers import on_unload diff --git a/homeassistant/components/neato/camera.py b/homeassistant/components/neato/camera.py index 6d4de68b456..d19bb2bb38b 100644 --- a/homeassistant/components/neato/camera.py +++ b/homeassistant/components/neato/camera.py @@ -10,12 +10,12 @@ from pybotvac.robot import Robot from urllib3.response import HTTPResponse from homeassistant.components.camera import Camera -from homeassistant.components.neato import NeatoHub from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import NeatoHub from .const import ( NEATO_DOMAIN, NEATO_LOGIN, diff --git a/homeassistant/components/neato/sensor.py b/homeassistant/components/neato/sensor.py index 1fd6547d926..3f7b925ef7f 100644 --- a/homeassistant/components/neato/sensor.py +++ b/homeassistant/components/neato/sensor.py @@ -8,7 +8,6 @@ from typing import Any from pybotvac.exceptions import NeatoRobotException from pybotvac.robot import Robot -from homeassistant.components.neato import NeatoHub from homeassistant.components.sensor import DEVICE_CLASS_BATTERY, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC, PERCENTAGE @@ -16,6 +15,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import NeatoHub from .const import NEATO_DOMAIN, NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/neato/switch.py b/homeassistant/components/neato/switch.py index b6a1302bda7..c34eea492e9 100644 --- a/homeassistant/components/neato/switch.py +++ b/homeassistant/components/neato/switch.py @@ -8,13 +8,13 @@ from typing import Any from pybotvac.exceptions import NeatoRobotException from pybotvac.robot import Robot -from homeassistant.components.neato import NeatoHub from homeassistant.config_entries import ConfigEntry from homeassistant.const import ENTITY_CATEGORY_CONFIG, STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo, ToggleEntity from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import NeatoHub from .const import NEATO_DOMAIN, NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/nexia/binary_sensor.py b/homeassistant/components/nexia/binary_sensor.py index 63fb98c9a0b..cddfb27845b 100644 --- a/homeassistant/components/nexia/binary_sensor.py +++ b/homeassistant/components/nexia/binary_sensor.py @@ -1,9 +1,9 @@ """Support for Nexia / Trane XL Thermostats.""" from homeassistant.components.binary_sensor import BinarySensorEntity -from homeassistant.components.nexia.coordinator import NexiaDataUpdateCoordinator from .const import DOMAIN +from .coordinator import NexiaDataUpdateCoordinator from .entity import NexiaThermostatEntity diff --git a/homeassistant/components/nsw_fuel_station/sensor.py b/homeassistant/components/nsw_fuel_station/sensor.py index 139728a3405..5e17c127c89 100644 --- a/homeassistant/components/nsw_fuel_station/sensor.py +++ b/homeassistant/components/nsw_fuel_station/sensor.py @@ -5,10 +5,6 @@ import logging import voluptuous as vol -from homeassistant.components.nsw_fuel_station import ( - DATA_NSW_FUEL_STATION, - StationPriceData, -) from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ATTR_ATTRIBUTION, CURRENCY_CENT, VOLUME_LITERS import homeassistant.helpers.config_validation as cv @@ -17,6 +13,8 @@ from homeassistant.helpers.update_coordinator import ( DataUpdateCoordinator, ) +from . import DATA_NSW_FUEL_STATION, StationPriceData + _LOGGER = logging.getLogger(__name__) ATTR_STATION_ID = "station_id" diff --git a/homeassistant/components/nut/sensor.py b/homeassistant/components/nut/sensor.py index e937e6565df..e83cf900b7e 100644 --- a/homeassistant/components/nut/sensor.py +++ b/homeassistant/components/nut/sensor.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging -from homeassistant.components.nut import PyNUTData from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.const import STATE_UNKNOWN from homeassistant.helpers.entity import DeviceInfo @@ -12,6 +11,7 @@ from homeassistant.helpers.update_coordinator import ( DataUpdateCoordinator, ) +from . import PyNUTData from .const import ( COORDINATOR, DOMAIN, diff --git a/homeassistant/components/onewire/binary_sensor.py b/homeassistant/components/onewire/binary_sensor.py index 945ec2344d4..0235b46baa6 100644 --- a/homeassistant/components/onewire/binary_sensor.py +++ b/homeassistant/components/onewire/binary_sensor.py @@ -10,7 +10,6 @@ from homeassistant.components.binary_sensor import ( BinarySensorEntity, BinarySensorEntityDescription, ) -from homeassistant.components.onewire.model import OWServerDeviceDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_TYPE from homeassistant.core import HomeAssistant @@ -25,6 +24,7 @@ from .const import ( DOMAIN, READ_MODE_BOOL, ) +from .model import OWServerDeviceDescription from .onewire_entities import OneWireEntityDescription, OneWireProxyEntity from .onewirehub import OneWireHub diff --git a/homeassistant/components/onewire/sensor.py b/homeassistant/components/onewire/sensor.py index ad6ad74989c..b0451be953b 100644 --- a/homeassistant/components/onewire/sensor.py +++ b/homeassistant/components/onewire/sensor.py @@ -11,10 +11,6 @@ from typing import TYPE_CHECKING, Any from pi1wire import InvalidCRCException, OneWireInterface, UnsupportResponseException -from homeassistant.components.onewire.model import ( - OWDirectDeviceDescription, - OWServerDeviceDescription, -) from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, @@ -46,6 +42,7 @@ from .const import ( READ_MODE_FLOAT, READ_MODE_INT, ) +from .model import OWDirectDeviceDescription, OWServerDeviceDescription from .onewire_entities import ( OneWireBaseEntity, OneWireEntityDescription, diff --git a/homeassistant/components/onewire/switch.py b/homeassistant/components/onewire/switch.py index a7dc1335a46..a05757936f9 100644 --- a/homeassistant/components/onewire/switch.py +++ b/homeassistant/components/onewire/switch.py @@ -5,7 +5,6 @@ from dataclasses import dataclass import os from typing import TYPE_CHECKING, Any -from homeassistant.components.onewire.model import OWServerDeviceDescription from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_TYPE @@ -21,6 +20,7 @@ from .const import ( DOMAIN, READ_MODE_BOOL, ) +from .model import OWServerDeviceDescription from .onewire_entities import OneWireEntityDescription, OneWireProxyEntity from .onewirehub import OneWireHub diff --git a/homeassistant/components/opengarage/entity.py b/homeassistant/components/opengarage/entity.py index 706ff0e81be..97a60d42c07 100644 --- a/homeassistant/components/opengarage/entity.py +++ b/homeassistant/components/opengarage/entity.py @@ -1,11 +1,12 @@ """Entity for the opengarage.io component.""" -from homeassistant.components.opengarage import DOMAIN from homeassistant.core import callback from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity +from . import DOMAIN + class OpenGarageEntity(CoordinatorEntity): """Representation of a OpenGarage entity.""" diff --git a/homeassistant/components/opnsense/device_tracker.py b/homeassistant/components/opnsense/device_tracker.py index 0bce00a8e82..9a024b2b260 100644 --- a/homeassistant/components/opnsense/device_tracker.py +++ b/homeassistant/components/opnsense/device_tracker.py @@ -1,6 +1,7 @@ """Device tracker support for OPNSense routers.""" from homeassistant.components.device_tracker import DeviceScanner -from homeassistant.components.opnsense import CONF_TRACKER_INTERFACE, OPNSENSE_DATA + +from . import CONF_TRACKER_INTERFACE, OPNSENSE_DATA async def async_get_scanner(hass, config, discovery_info=None): diff --git a/homeassistant/components/pi_hole/config_flow.py b/homeassistant/components/pi_hole/config_flow.py index 5acaffd13b1..39d47ecdd74 100644 --- a/homeassistant/components/pi_hole/config_flow.py +++ b/homeassistant/components/pi_hole/config_flow.py @@ -9,16 +9,6 @@ from hole.exceptions import HoleError import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.pi_hole.const import ( - CONF_LOCATION, - CONF_STATISTICS_ONLY, - DEFAULT_LOCATION, - DEFAULT_NAME, - DEFAULT_SSL, - DEFAULT_STATISTICS_ONLY, - DEFAULT_VERIFY_SSL, - DOMAIN, -) from homeassistant.const import ( CONF_API_KEY, CONF_HOST, @@ -30,6 +20,17 @@ from homeassistant.const import ( from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.aiohttp_client import async_get_clientsession +from .const import ( + CONF_LOCATION, + CONF_STATISTICS_ONLY, + DEFAULT_LOCATION, + DEFAULT_NAME, + DEFAULT_SSL, + DEFAULT_STATISTICS_ONLY, + DEFAULT_VERIFY_SSL, + DOMAIN, +) + _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/pilight/base_class.py b/homeassistant/components/pilight/base_class.py index 97ebaef0080..517beab850f 100644 --- a/homeassistant/components/pilight/base_class.py +++ b/homeassistant/components/pilight/base_class.py @@ -1,7 +1,6 @@ """Base class for pilight.""" import voluptuous as vol -from homeassistant.components.pilight import DOMAIN, EVENT, SERVICE_NAME from homeassistant.const import ( CONF_ID, CONF_NAME, @@ -13,6 +12,7 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv from homeassistant.helpers.restore_state import RestoreEntity +from . import DOMAIN, EVENT, SERVICE_NAME from .const import ( CONF_ECHO, CONF_OFF, diff --git a/homeassistant/components/ps4/media_player.py b/homeassistant/components/ps4/media_player.py index cc096e96bd5..8f3cfcb0e4b 100644 --- a/homeassistant/components/ps4/media_player.py +++ b/homeassistant/components/ps4/media_player.py @@ -19,7 +19,6 @@ from homeassistant.components.media_player.const import ( SUPPORT_TURN_OFF, SUPPORT_TURN_ON, ) -from homeassistant.components.ps4 import format_unique_id, load_games, save_games from homeassistant.const import ( ATTR_LOCKED, CONF_HOST, @@ -34,6 +33,7 @@ from homeassistant.core import callback from homeassistant.helpers import device_registry, entity_registry from homeassistant.helpers.entity import DeviceInfo +from . import format_unique_id, load_games, save_games from .const import ( ATTR_MEDIA_IMAGE_URL, DEFAULT_ALIAS, diff --git a/homeassistant/components/recorder/history.py b/homeassistant/components/recorder/history.py index 72f820a0d3b..8be60a60ac6 100644 --- a/homeassistant/components/recorder/history.py +++ b/homeassistant/components/recorder/history.py @@ -10,15 +10,11 @@ from sqlalchemy import and_, bindparam, func from sqlalchemy.ext import baked from homeassistant.components import recorder -from homeassistant.components.recorder.models import ( - States, - process_timestamp_to_utc_isoformat, -) -from homeassistant.components.recorder.util import execute, session_scope from homeassistant.core import split_entity_id import homeassistant.util.dt as dt_util -from .models import LazyState +from .models import LazyState, States, process_timestamp_to_utc_isoformat +from .util import execute, session_scope # mypy: allow-untyped-defs, no-check-untyped-defs diff --git a/homeassistant/components/rfxtrx/device_trigger.py b/homeassistant/components/rfxtrx/device_trigger.py index 25c8825f6ed..9ab10ca7f2b 100644 --- a/homeassistant/components/rfxtrx/device_trigger.py +++ b/homeassistant/components/rfxtrx/device_trigger.py @@ -12,7 +12,6 @@ from homeassistant.components.device_automation.exceptions import ( InvalidDeviceAutomationConfig, ) from homeassistant.components.homeassistant.triggers import event as event_trigger -from homeassistant.components.rfxtrx.const import EVENT_RFXTRX_EVENT from homeassistant.const import ( ATTR_DEVICE_ID, CONF_DEVICE_ID, @@ -24,6 +23,7 @@ from homeassistant.core import CALLBACK_TYPE, HomeAssistant from homeassistant.helpers.typing import ConfigType from . import DOMAIN +from .const import EVENT_RFXTRX_EVENT from .helpers import async_get_device_object CONF_SUBTYPE = "subtype"