Move late import of config flows in loader to load time (#110688)

* Move late import of config flows in loader to load time

There does not seem to be any reason to import the
generated flows late. Import them at load time
with the rest of the generated files

* tests
This commit is contained in:
J. Nick Koston 2024-02-16 00:55:12 -06:00 committed by GitHub
parent 1608e05be6
commit 37897ee384
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 8 deletions

View File

@ -28,6 +28,7 @@ from . import generated
from .core import HomeAssistant, callback
from .generated.application_credentials import APPLICATION_CREDENTIALS
from .generated.bluetooth import BLUETOOTH
from .generated.config_flows import FLOWS
from .generated.dhcp import DHCP
from .generated.mqtt import MQTT
from .generated.ssdp import SSDP
@ -260,9 +261,6 @@ async def async_get_config_flows(
type_filter: Literal["device", "helper", "hub", "service"] | None = None,
) -> set[str]:
"""Return cached list of config flows."""
# pylint: disable-next=import-outside-toplevel
from .generated.config_flows import FLOWS
integrations = await async_get_custom_components(hass)
flows: set[str] = set()

View File

@ -6,12 +6,11 @@ from unittest.mock import ANY, AsyncMock, patch
import pytest
import voluptuous as vol
from homeassistant import config_entries as core_ce, data_entry_flow
from homeassistant import config_entries as core_ce, data_entry_flow, loader
from homeassistant.components.config import config_entries
from homeassistant.config_entries import HANDLERS, ConfigFlow
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
from homeassistant.core import HomeAssistant, callback
from homeassistant.generated import config_flows
from homeassistant.helpers import config_entry_flow, config_validation as cv
from homeassistant.loader import IntegrationNotFound
from homeassistant.setup import async_setup_component
@ -334,7 +333,7 @@ async def test_available_flows(
) -> None:
"""Test querying the available flows."""
with patch.object(
config_flows,
loader,
"FLOWS",
{"integration": ["hello", "another"], "helper": ["world"]},
):

View File

@ -6,9 +6,9 @@ from unittest.mock import Mock, call, patch
import pytest
from homeassistant import loader
from homeassistant.const import EVENT_COMPONENT_LOADED, EVENT_CORE_CONFIG_UPDATE
from homeassistant.core import HomeAssistant
from homeassistant.generated import config_flows
from homeassistant.helpers import translation
from homeassistant.loader import async_get_integration
from homeassistant.setup import async_setup_component
@ -18,7 +18,7 @@ from homeassistant.setup import async_setup_component
def mock_config_flows():
"""Mock the config flows."""
flows = {"integration": [], "helper": {}}
with patch.object(config_flows, "FLOWS", flows):
with patch.object(loader, "FLOWS", flows):
yield flows