Fix circular import of config_validation and template (#41802)
This commit is contained in:
parent
956e3b4451
commit
b1ed5a3e79
2 changed files with 9 additions and 2 deletions
|
@ -7,7 +7,6 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
|
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
|
||||||
from homeassistant.core import State
|
from homeassistant.core import State
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
from homeassistant.util import location as loc_util
|
from homeassistant.util import location as loc_util
|
||||||
|
|
||||||
|
@ -91,6 +90,9 @@ def find_coordinates(
|
||||||
|
|
||||||
# Check if state is valid coordinate set
|
# Check if state is valid coordinate set
|
||||||
try:
|
try:
|
||||||
|
# Import here, not at top-level to avoid circular import
|
||||||
|
import homeassistant.helpers.config_validation as cv # pylint: disable=import-outside-toplevel
|
||||||
|
|
||||||
cv.gps(entity_state.state.split(","))
|
cv.gps(entity_state.state.split(","))
|
||||||
except vol.Invalid:
|
except vol.Invalid:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
|
|
@ -31,7 +31,7 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.core import State, callback, split_entity_id, valid_entity_id
|
from homeassistant.core import State, callback, split_entity_id, valid_entity_id
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
from homeassistant.helpers import config_validation as cv, location as loc_helper
|
from homeassistant.helpers import location as loc_helper
|
||||||
from homeassistant.helpers.typing import HomeAssistantType, TemplateVarsType
|
from homeassistant.helpers.typing import HomeAssistantType, TemplateVarsType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util import convert, dt as dt_util, location as loc_util
|
from homeassistant.util import convert, dt as dt_util, location as loc_util
|
||||||
|
@ -791,6 +791,11 @@ def result_as_boolean(template_result: Optional[str]) -> bool:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
# Import here, not at top-level to avoid circular import
|
||||||
|
from homeassistant.helpers import ( # pylint: disable=import-outside-toplevel
|
||||||
|
config_validation as cv,
|
||||||
|
)
|
||||||
|
|
||||||
return cv.boolean(template_result)
|
return cv.boolean(template_result)
|
||||||
except vol.Invalid:
|
except vol.Invalid:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue