Repository: home-assistant/core
File: homeassistant/components/uptimerobot/config_flow.py (Python)

Code before:
        except UptimeRobotException:
            errors["base"] = "cannot_connect"
        except Exception as exception:  # noqa: BLE001
            LOGGER.exception(exception)
            errors["base"] = "unknown"

        if TYPE_CHECKING:
            assert response is not None
            assert isinstance(response.data, UptimeRobotAccount)

        account: UptimeRobotAccount | None = response.data if response else None

        return errors, account

    async def async_step_user(
        self, user_input: dict[str, Any] | None = None
    ) -> ConfigFlowResult:
        """Handle the initial step."""
        if user_input is None:
            return self.async_show_form(
                step_id="user", data_schema=STEP_USER_DATA_SCHEMA
            )

        errors, account = await self._validate_input(user_input)
        if account:
            await self.async_set_unique_id(str(account.email))
            self._abort_if_unique_id_configured()
            return self.async_create_entry(title=account.email, data=user_input)

        return self.async_show_form(
            step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
        )

    async def async_step_reauth(
        self, entry_data: Mapping[str, Any]
    ) -> ConfigFlowResult:
        """Return the reauth confirm step."""
        return await self.async_step_reauth_confirm()

    async def async_step_reauth_confirm(
        self, user_input: dict[str, Any] | None = None
    ) -> ConfigFlowResult:
        """Dialog that informs the user that reauth is required."""
        if user_input is None:
            return self.async_show_form(
                step_id="reauth_confirm", data_schema=STEP_USER_DATA_SCHEMA
            )
        errors, account = await self._validate_input(user_input)
        if account:
            if self.context.get("unique_id") and self.context["unique_id"] != str(
                account.email

Review comment (suggestion):
1. Was the user id always the email? If not, we should probably migrate
2. We don't need to `str()` the email as it likely already is a string

Code after:
        except UptimeRobotException:
            errors["base"] = "cannot_connect"
        except Exception as exception:  # noqa: BLE001
            LOGGER.exception(exception)
            errors["base"] = "unknown"

        if TYPE_CHECKING:
            assert response is not None
            assert isinstance(response.data, UptimeRobotAccount)

        account: UptimeRobotAccount | None = response.data if response else None

        return errors, account

    async def async_step_user(
        self, user_input: dict[str, Any] | None = None
    ) -> ConfigFlowResult:
        """Handle the initial step."""
        if user_input is None:
            return self.async_show_form(
                step_id="user", data_schema=STEP_USER_DATA_SCHEMA
            )

        errors, account = await self._validate_input(user_input)
        if account:
            await self.async_set_unique_id(account.email)
            self._abort_if_unique_id_configured()
            return self.async_create_entry(title=account.email, data=user_input)

        return self.async_show_form(
            step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
        )

    async def async_step_reauth(
        self, entry_data: Mapping[str, Any]
    ) -> ConfigFlowResult:
        """Return the reauth confirm step."""
        return await self.async_step_reauth_confirm()

    async def async_step_reauth_confirm(
        self, user_input: dict[str, Any] | None = None
    ) -> ConfigFlowResult:
        """Dialog that informs the user that reauth is required."""
        if user_input is None:
            return self.async_show_form(
                step_id="reauth_confirm", data_schema=STEP_USER_DATA_SCHEMA
            )
        errors, account = await self._validate_input(user_input)
        if account:
            if (
                self.context.get("unique_id")