Improve config flow type hints in volumio (#125318)
This commit is contained in:
parent
ba81a68982
commit
053e38db38
1 changed files with 11 additions and 11 deletions
|
@ -11,7 +11,7 @@ import voluptuous as vol
|
|||
from homeassistant.components import zeroconf
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
|
@ -25,7 +25,7 @@ DATA_SCHEMA = vol.Schema(
|
|||
)
|
||||
|
||||
|
||||
async def validate_input(hass, host, port):
|
||||
async def validate_input(hass: HomeAssistant, host: str, port: int) -> dict[str, Any]:
|
||||
"""Validate the user input allows us to connect."""
|
||||
volumio = Volumio(host, port, async_get_clientsession(hass))
|
||||
|
||||
|
@ -40,15 +40,13 @@ class VolumioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize flow."""
|
||||
self._host: str | None = None
|
||||
self._port: int | None = None
|
||||
self._name: str | None = None
|
||||
self._uuid: str | None = None
|
||||
_host: str
|
||||
_port: int
|
||||
_name: str
|
||||
_uuid: str | None
|
||||
|
||||
@callback
|
||||
def _async_get_entry(self):
|
||||
def _async_get_entry(self) -> ConfigFlowResult:
|
||||
return self.async_create_entry(
|
||||
title=self._name,
|
||||
data={
|
||||
|
@ -103,7 +101,7 @@ class VolumioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
) -> ConfigFlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
self._host = discovery_info.host
|
||||
self._port = discovery_info.port
|
||||
self._port = discovery_info.port or 3000
|
||||
self._name = discovery_info.properties["volumioName"]
|
||||
self._uuid = discovery_info.properties["UUID"]
|
||||
|
||||
|
@ -111,7 +109,9 @@ class VolumioConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
return await self.async_step_discovery_confirm()
|
||||
|
||||
async def async_step_discovery_confirm(self, user_input=None):
|
||||
async def async_step_discovery_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle user-confirmation of discovered node."""
|
||||
if user_input is not None:
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue