Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve config flow type hints in volumio #125318

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions homeassistant/components/volumio/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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

Expand All @@ -25,7 +25,7 @@
)


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))

Expand All @@ -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={
Expand Down Expand Up @@ -103,15 +101,17 @@ async def async_step_zeroconf(
) -> 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"]

await self._set_uid_and_abort()

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:
Expand Down