Skip to content

Commit

Permalink
Unpack non-performant any expressions in config flow discovery path (h…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Aug 3, 2024
1 parent 02f81ec commit b6de2cd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,10 +1245,10 @@ async def async_wait_import_flow_initialized(self, handler: str) -> None:
@callback
def _async_has_other_discovery_flows(self, flow_id: str) -> bool:
"""Check if there are any other discovery flows in progress."""
return any(
flow.context["source"] in DISCOVERY_SOURCES and flow.flow_id != flow_id
for flow in self._progress.values()
)
for flow in self._progress.values():
if flow.flow_id != flow_id and flow.context["source"] in DISCOVERY_SOURCES:
return True
return False

async def async_init(
self, handler: str, *, context: dict[str, Any] | None = None, data: Any = None
Expand Down Expand Up @@ -1699,12 +1699,12 @@ def async_has_entries(
entries = self._entries.get_entries_for_domain(domain)
if include_ignore and include_disabled:
return bool(entries)
return any(
entry
for entry in entries
if (include_ignore or entry.source != SOURCE_IGNORE)
and (include_disabled or not entry.disabled_by)
)
for entry in entries:
if (include_ignore or entry.source != SOURCE_IGNORE) and (
include_disabled or not entry.disabled_by
):
return True
return False

@callback
def async_entries(
Expand Down

0 comments on commit b6de2cd

Please sign in to comment.