mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
None optional hass typing in FlowHandler (#46462)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
@@ -903,7 +903,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
reload_on_update: bool = True,
|
||||
) -> None:
|
||||
"""Abort if the unique ID is already configured."""
|
||||
assert self.hass
|
||||
if self.unique_id is None:
|
||||
return
|
||||
|
||||
@@ -945,7 +944,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
self.context["unique_id"] = unique_id # pylint: disable=no-member
|
||||
|
||||
# Abort discoveries done using the default discovery unique id
|
||||
assert self.hass is not None
|
||||
if unique_id != DEFAULT_DISCOVERY_UNIQUE_ID:
|
||||
for progress in self._async_in_progress():
|
||||
if progress["context"].get("unique_id") == DEFAULT_DISCOVERY_UNIQUE_ID:
|
||||
@@ -963,7 +961,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
|
||||
If the flow is user initiated, filter out ignored entries unless include_ignore is True.
|
||||
"""
|
||||
assert self.hass is not None
|
||||
config_entries = self.hass.config_entries.async_entries(self.handler)
|
||||
|
||||
if include_ignore or self.source != SOURCE_USER:
|
||||
@@ -974,7 +971,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
@callback
|
||||
def _async_current_ids(self, include_ignore: bool = True) -> Set[Optional[str]]:
|
||||
"""Return current unique IDs."""
|
||||
assert self.hass is not None
|
||||
return {
|
||||
entry.unique_id
|
||||
for entry in self.hass.config_entries.async_entries(self.handler)
|
||||
@@ -984,7 +980,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
@callback
|
||||
def _async_in_progress(self) -> List[Dict]:
|
||||
"""Return other in progress flows for current domain."""
|
||||
assert self.hass is not None
|
||||
return [
|
||||
flw
|
||||
for flw in self.hass.config_entries.flow.async_progress()
|
||||
@@ -1027,7 +1022,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
# Abort if any other flow for this handler is already in progress
|
||||
assert self.hass is not None
|
||||
if self._async_in_progress():
|
||||
raise data_entry_flow.AbortFlow("already_in_progress")
|
||||
|
||||
@@ -1043,8 +1037,6 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||
self, *, reason: str, description_placeholders: Optional[Dict] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""Abort the config flow."""
|
||||
assert self.hass
|
||||
|
||||
# Remove reauth notification if no reauth flows are in progress
|
||||
if self.source == SOURCE_REAUTH and not any(
|
||||
ent["context"]["source"] == SOURCE_REAUTH
|
||||
|
||||
Reference in New Issue
Block a user