Rename supported_subentry_flows to supported_subentry_types

This commit is contained in:
Erik 2025-01-07 13:04:29 +01:00
parent 8541e6e9cd
commit f6214a22c1
3 changed files with 62 additions and 62 deletions

View File

@ -399,7 +399,7 @@ class ConfigEntry(Generic[_DataT]):
supports_remove_device: bool | None
_supports_options: bool | None
_supports_reconfigure: bool | None
_supported_subentry_flows: dict[str, dict[str, bool]] | None
_supported_subentry_types: dict[str, dict[str, bool]] | None
update_listeners: list[UpdateListenerType]
_async_cancel_retry_setup: Callable[[], Any] | None
_on_unload: list[Callable[[], Coroutine[Any, Any, None] | None]] | None
@ -511,7 +511,7 @@ class ConfigEntry(Generic[_DataT]):
_setter(self, "_supports_reconfigure", None)
# Supports subentries
_setter(self, "_supported_subentry_flows", None)
_setter(self, "_supported_subentry_types", None)
# Listeners to call on update
_setter(self, "update_listeners", [])
@ -586,16 +586,16 @@ class ConfigEntry(Generic[_DataT]):
return self._supports_reconfigure or False
@property
def supported_subentry_flows(self) -> dict[str, dict[str, bool]]:
"""Return supported subentries."""
if self._supported_subentry_flows is None and (
def supported_subentry_types(self) -> dict[str, dict[str, bool]]:
"""Return supported subentry types."""
if self._supported_subentry_types is None and (
handler := HANDLERS.get(self.domain)
):
# work out sub entries supported by the handler
supported_flows = handler.async_get_supported_subentry_flows(self)
supported_flows = handler.async_get_supported_subentry_types(self)
object.__setattr__(
self,
"_supported_subentry_flows",
"_supported_subentry_types",
{
subentry_flow_type: {
"supports_reconfigure": hasattr(
@ -605,7 +605,7 @@ class ConfigEntry(Generic[_DataT]):
for subentry_flow_type, subentry_flow_handler in supported_flows.items()
},
)
return self._supported_subentry_flows or {}
return self._supported_subentry_types or {}
def clear_state_cache(self) -> None:
"""Clear cached properties that are included in as_json_fragment."""
@ -626,7 +626,7 @@ class ConfigEntry(Generic[_DataT]):
"supports_remove_device": self.supports_remove_device or False,
"supports_unload": self.supports_unload or False,
"supports_reconfigure": self.supports_reconfigure,
"supported_subentry_flows": self.supported_subentry_flows,
"supported_subentry_types": self.supported_subentry_types,
"pref_disable_new_entities": self.pref_disable_new_entities,
"pref_disable_polling": self.pref_disable_polling,
"disabled_by": self.disabled_by,
@ -2838,7 +2838,7 @@ class ConfigFlow(ConfigEntryBaseFlow):
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[ConfigSubentryFlow]]:
"""Return subentries supported by this handler."""
@ -3324,12 +3324,12 @@ class ConfigSubentryFlowManager(
entry_id, subentry_type = handler_key
entry = self._async_get_config_entry(entry_id)
handler = await _async_get_flow_handler(self.hass, entry.domain, {})
subentry_flows = handler.async_get_supported_subentry_flows(entry)
if subentry_type not in subentry_flows:
subentry_types = handler.async_get_supported_subentry_types(entry)
if subentry_type not in subentry_types:
raise data_entry_flow.UnknownHandler(
f"Config entry '{entry.domain}' does not support subentry '{subentry_type}'"
)
subentry_flow = subentry_flows[subentry_type]()
subentry_flow = subentry_types[subentry_type]()
subentry_flow.init_step = context["source"]
return subentry_flow

View File

@ -143,7 +143,7 @@ async def test_get_entries(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": "bla",
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": True,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -163,7 +163,7 @@ async def test_get_entries(hass: HomeAssistant, client: TestClient) -> None:
"reason": "Unsupported API",
"source": "bla2",
"state": core_ce.ConfigEntryState.SETUP_ERROR.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -183,7 +183,7 @@ async def test_get_entries(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": "bla3",
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -203,7 +203,7 @@ async def test_get_entries(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": "bla4",
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -223,7 +223,7 @@ async def test_get_entries(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": "bla5",
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -587,7 +587,7 @@ async def test_create_account(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": core_ce.SOURCE_USER,
"state": core_ce.ConfigEntryState.LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -673,7 +673,7 @@ async def test_two_step_flow(hass: HomeAssistant, client: TestClient) -> None:
"reason": None,
"source": core_ce.SOURCE_USER,
"state": core_ce.ConfigEntryState.LOADED.value,
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1123,7 +1123,7 @@ async def test_subentry_flow(hass: HomeAssistant, client) -> None:
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: core_ce.ConfigEntry
) -> dict[str, type[core_ce.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -1179,7 +1179,7 @@ async def test_subentry_reconfigure_flow(hass: HomeAssistant, client) -> None:
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: core_ce.ConfigEntry
) -> dict[str, type[core_ce.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -1250,7 +1250,7 @@ async def test_subentry_flow_unauth(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: core_ce.ConfigEntry
) -> dict[str, type[core_ce.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -1296,7 +1296,7 @@ async def test_two_step_subentry_flow(hass: HomeAssistant, client) -> None:
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: core_ce.ConfigEntry
) -> dict[str, type[core_ce.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -1376,7 +1376,7 @@ async def test_subentry_flow_with_invalid_data(hass: HomeAssistant, client) -> N
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: core_ce.ConfigEntry
) -> dict[str, type[core_ce.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -1462,7 +1462,7 @@ async def test_get_single(
"reason": None,
"source": "user",
"state": "loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1824,7 +1824,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1845,7 +1845,7 @@ async def test_get_matching_entries_ws(
"reason": "Unsupported API",
"source": "bla2",
"state": "setup_error",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1866,7 +1866,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1887,7 +1887,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla4",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1908,7 +1908,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla5",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1940,7 +1940,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1971,7 +1971,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla4",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -1992,7 +1992,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla5",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2023,7 +2023,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2044,7 +2044,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2081,7 +2081,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2102,7 +2102,7 @@ async def test_get_matching_entries_ws(
"reason": "Unsupported API",
"source": "bla2",
"state": "setup_error",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2123,7 +2123,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2144,7 +2144,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla4",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2165,7 +2165,7 @@ async def test_get_matching_entries_ws(
"reason": None,
"source": "bla5",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2274,7 +2274,7 @@ async def test_subscribe_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2298,7 +2298,7 @@ async def test_subscribe_entries_ws(
"reason": "Unsupported API",
"source": "bla2",
"state": "setup_error",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2322,7 +2322,7 @@ async def test_subscribe_entries_ws(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2352,7 +2352,7 @@ async def test_subscribe_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2383,7 +2383,7 @@ async def test_subscribe_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2413,7 +2413,7 @@ async def test_subscribe_entries_ws(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2505,7 +2505,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2529,7 +2529,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2561,7 +2561,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2589,7 +2589,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla3",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2621,7 +2621,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,
@ -2651,7 +2651,7 @@ async def test_subscribe_entries_ws_filtered(
"reason": None,
"source": "bla",
"state": "not_loaded",
"supported_subentry_flows": {},
"supported_subentry_types": {},
"supports_options": False,
"supports_reconfigure": False,
"supports_remove_device": False,

View File

@ -1968,7 +1968,7 @@ async def test_create_entry_subentries(
entries = hass.config_entries.async_entries("comp")
assert len(entries) == 1
assert entries[0].supported_subentry_flows == {}
assert entries[0].supported_subentry_types == {}
assert entries[0].data == {"example": "data"}
assert len(entries[0].subentries) == 1
subentry_id = list(entries[0].subentries)[0]
@ -1999,7 +1999,7 @@ async def test_entry_subentry(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2033,7 +2033,7 @@ async def test_entry_subentry(
unique_id="test",
)
}
assert entry.supported_subentry_flows == {
assert entry.supported_subentry_types == {
"test": {"supports_reconfigure": False}
}
@ -2055,7 +2055,7 @@ async def test_entry_subentry_non_string(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2097,7 +2097,7 @@ async def test_entry_subentry_no_context(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2144,7 +2144,7 @@ async def test_entry_subentry_duplicate(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2185,7 +2185,7 @@ async def test_entry_subentry_abort(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2232,7 +2232,7 @@ async def test_entry_subentry_deleted_config_entry(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}
@ -2275,7 +2275,7 @@ async def test_entry_subentry_unsupported_subentry_type(
@classmethod
@callback
def async_get_supported_subentry_flows(
def async_get_supported_subentry_types(
cls, config_entry: ConfigEntry
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
return {"test": TestFlow.SubentryFlowHandler}