1
mirror of https://github.com/home-assistant/core synced 2024-09-09 12:51:22 +02:00

Fix referenced before assignment in modem_callerid (#57460)

This commit is contained in:
Robert Hillis 2021-10-11 05:36:53 -04:00 committed by GitHub
parent d84722c3c2
commit 8275110c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> FlowResult:
"""Handle a flow initiated by the user.""" """Handle a flow initiated by the user."""
errors: dict[str, str] | None = {}
if self._async_in_progress(): if self._async_in_progress():
return self.async_abort(reason="already_in_progress") return self.async_abort(reason="already_in_progress")
ports = await self.hass.async_add_executor_job(serial.tools.list_ports.comports) ports = await self.hass.async_add_executor_job(serial.tools.list_ports.comports)
@ -88,7 +89,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
dev_path = await self.hass.async_add_executor_job( dev_path = await self.hass.async_add_executor_job(
usb.get_serial_by_id, port.device usb.get_serial_by_id, port.device
) )
errors: dict | None = await self.validate_device_errors( errors = await self.validate_device_errors(
dev_path=dev_path, unique_id=_generate_unique_id(port) dev_path=dev_path, unique_id=_generate_unique_id(port)
) )
if errors is None: if errors is None:
@ -98,9 +99,7 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
) )
user_input = user_input or {} user_input = user_input or {}
schema = vol.Schema({vol.Required(CONF_DEVICE): vol.In(unused_ports)}) schema = vol.Schema({vol.Required(CONF_DEVICE): vol.In(unused_ports)})
return self.async_show_form( return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
step_id="user", data_schema=schema, errors=errors or {}
)
async def async_step_import(self, config: dict[str, Any]) -> FlowResult: async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
"""Import a config entry from configuration.yaml.""" """Import a config entry from configuration.yaml."""