Use _get_reauth/reconfigure_entry in pyload (#127304)

This commit is contained in:
epenet 2024-10-03 10:18:10 +02:00 committed by GitHub
parent 409d7b3652
commit 2e225dfc3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Mapping
import logging
from typing import TYPE_CHECKING, Any
from typing import Any
from aiohttp import CookieJar
from pyloadapi.api import PyLoadAPI
@ -101,7 +101,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for pyLoad."""
VERSION = 1
config_entry: PyLoadConfigEntry | None
config_entry: PyLoadConfigEntry
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@ -156,9 +156,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self.config_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
self.config_entry = self._get_reauth_entry()
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
@ -167,9 +165,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
"""Dialog that informs the user that reauth is required."""
errors = {}
if TYPE_CHECKING:
assert self.config_entry
if user_input is not None:
new_input = self.config_entry.data | user_input
try:
@ -204,9 +199,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Perform a reconfiguration."""
self.config_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
self.config_entry = self._get_reconfigure_entry()
return await self.async_step_reconfigure_confirm()
async def async_step_reconfigure_confirm(
@ -215,9 +208,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle the reconfiguration flow."""
errors = {}
if TYPE_CHECKING:
assert self.config_entry
if user_input is not None:
try:
await validate_input(self.hass, user_input)