mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Mark config dependency of frontend (#36587)
This commit is contained in:
parent
29b8f76e57
commit
8f3c84b349
@ -50,7 +50,6 @@ STAGE_1_INTEGRATIONS = {
|
|||||||
# as possible so problem integrations can
|
# as possible so problem integrations can
|
||||||
# be removed
|
# be removed
|
||||||
"frontend",
|
"frontend",
|
||||||
"config",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
"automation",
|
"automation",
|
||||||
"cloud",
|
"cloud",
|
||||||
"config",
|
|
||||||
"frontend",
|
"frontend",
|
||||||
"history",
|
"history",
|
||||||
"logbook",
|
"logbook",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
"api",
|
"api",
|
||||||
"auth",
|
"auth",
|
||||||
|
"config",
|
||||||
"device_automation",
|
"device_automation",
|
||||||
"http",
|
"http",
|
||||||
"lovelace",
|
"lovelace",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
"name": "Safe Mode",
|
"name": "Safe Mode",
|
||||||
"config_flow": false,
|
"config_flow": false,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/safe_mode",
|
"documentation": "https://www.home-assistant.io/integrations/safe_mode",
|
||||||
"dependencies": ["frontend", "config", "persistent_notification", "cloud"],
|
"dependencies": ["frontend", "persistent_notification", "cloud"],
|
||||||
"codeowners": ["@home-assistant/core"]
|
"codeowners": ["@home-assistant/core"]
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,8 @@ from typing import Any, Callable, Collection, Dict, Optional, Union
|
|||||||
|
|
||||||
from homeassistant import core, setup
|
from homeassistant import core, setup
|
||||||
from homeassistant.const import ATTR_DISCOVERED, ATTR_SERVICE, EVENT_PLATFORM_DISCOVERED
|
from homeassistant.const import ATTR_DISCOVERED, ATTR_SERVICE, EVENT_PLATFORM_DISCOVERED
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.loader import DEPENDENCY_BLACKLIST, bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_callback_threadsafe
|
||||||
|
|
||||||
EVENT_LOAD_PLATFORM = "load_platform.{}"
|
EVENT_LOAD_PLATFORM = "load_platform.{}"
|
||||||
@ -79,9 +78,6 @@ async def async_discover(
|
|||||||
hass_config: ConfigType,
|
hass_config: ConfigType,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Fire discovery event. Can ensure a component is loaded."""
|
"""Fire discovery event. Can ensure a component is loaded."""
|
||||||
if component in DEPENDENCY_BLACKLIST:
|
|
||||||
raise HomeAssistantError(f"Cannot discover the {component} component.")
|
|
||||||
|
|
||||||
if component is not None and component not in hass.config.components:
|
if component is not None and component not in hass.config.components:
|
||||||
await setup.async_setup_component(hass, component, hass_config)
|
await setup.async_setup_component(hass, component, hass_config)
|
||||||
|
|
||||||
@ -181,9 +177,6 @@ async def async_load_platform(
|
|||||||
"""
|
"""
|
||||||
assert hass_config, "You need to pass in the real hass config"
|
assert hass_config, "You need to pass in the real hass config"
|
||||||
|
|
||||||
if component in DEPENDENCY_BLACKLIST:
|
|
||||||
raise HomeAssistantError(f"Cannot discover the {component} component.")
|
|
||||||
|
|
||||||
setup_success = True
|
setup_success = True
|
||||||
|
|
||||||
if component not in hass.config.components:
|
if component not in hass.config.components:
|
||||||
|
@ -31,8 +31,6 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
|
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
|
||||||
|
|
||||||
DEPENDENCY_BLACKLIST = {"config"}
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_COMPONENTS = "components"
|
DATA_COMPONENTS = "components"
|
||||||
|
@ -59,17 +59,6 @@ async def _async_process_dependencies(
|
|||||||
hass: core.HomeAssistant, config: ConfigType, name: str, dependencies: List[str]
|
hass: core.HomeAssistant, config: ConfigType, name: str, dependencies: List[str]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Ensure all dependencies are set up."""
|
"""Ensure all dependencies are set up."""
|
||||||
blacklisted = [dep for dep in dependencies if dep in loader.DEPENDENCY_BLACKLIST]
|
|
||||||
|
|
||||||
if blacklisted and name not in ("default_config", "safe_mode"):
|
|
||||||
_LOGGER.error(
|
|
||||||
"Unable to set up dependencies of %s: "
|
|
||||||
"found blacklisted dependencies: %s",
|
|
||||||
name,
|
|
||||||
", ".join(blacklisted),
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
tasks = [async_setup_component(hass, dep, config) for dep in dependencies]
|
tasks = [async_setup_component(hass, dep, config) for dep in dependencies]
|
||||||
|
|
||||||
if not tasks:
|
if not tasks:
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
"""Test discovery helpers."""
|
"""Test discovery helpers."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from homeassistant import setup
|
from homeassistant import setup
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
@ -216,15 +213,3 @@ class TestHelpersDiscovery:
|
|||||||
|
|
||||||
# test_component will only be setup once
|
# test_component will only be setup once
|
||||||
assert len(component_calls) == 1
|
assert len(component_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_load_platform_forbids_config():
|
|
||||||
"""Test you cannot setup config component with load_platform."""
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
await discovery.async_load_platform(None, "config", "zwave", {}, {"config": {}})
|
|
||||||
|
|
||||||
|
|
||||||
async def test_discover_forbids_config():
|
|
||||||
"""Test you cannot setup config component with load_platform."""
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
await discovery.async_discover(None, None, None, "config", {})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user