Skip to content

Commit

Permalink
Move late import of config flows in loader to load time (#110688)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bdraco authored Feb 16, 2024
1 parent 1608e05 commit 37897ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions homeassistant/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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
Expand Down Expand Up @@ -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()

Expand Down
5 changes: 2 additions & 3 deletions tests/components/config/test_config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
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
Expand Down Expand Up @@ -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"]},
):
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/test_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

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
Expand All @@ -18,7 +18,7 @@
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


Expand Down

0 comments on commit 37897ee

Please sign in to comment.