Fix pylint/mypy on elmax integration (#112211)

elmax: config_flow: fix mypy/pylint

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2024-03-04 13:36:37 +00:00 committed by GitHub
parent b381922a20
commit a55fb1184a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,6 @@ import voluptuous as vol
from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.data_entry_flow import FlowResult
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from .common import ( from .common import (
@ -118,13 +117,13 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle the flow initiated by the user.""" """Handle the flow initiated by the user."""
return await self.async_step_choose_mode(user_input=user_input) return await self.async_step_choose_mode(user_input=user_input)
async def async_step_choose_mode( async def async_step_choose_mode(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle local vs cloud mode selection step.""" """Handle local vs cloud mode selection step."""
return self.async_show_menu( return self.async_show_menu(
step_id="choose_mode", step_id="choose_mode",
@ -136,7 +135,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
async def _handle_direct_and_create_entry( async def _handle_direct_and_create_entry(
self, fallback_step_id: str, schema: vol.Schema self, fallback_step_id: str, schema: vol.Schema
) -> FlowResult: ) -> ConfigFlowResult:
return await self._test_direct_and_create_entry() return await self._test_direct_and_create_entry()
async def _test_direct_and_create_entry(self): async def _test_direct_and_create_entry(self):
@ -202,7 +201,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
}, },
) )
async def async_step_direct(self, user_input: dict[str, Any]) -> FlowResult: async def async_step_direct(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Handle the direct setup step.""" """Handle the direct setup step."""
self._selected_mode = CONF_ELMAX_MODE_CLOUD self._selected_mode = CONF_ELMAX_MODE_CLOUD
if user_input is None: if user_input is None:
@ -236,7 +235,9 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
fallback_step_id=CONF_ELMAX_MODE_DIRECT, schema=tmp_schema fallback_step_id=CONF_ELMAX_MODE_DIRECT, schema=tmp_schema
) )
async def async_step_zeroconf_setup(self, user_input: dict[str, Any]) -> FlowResult: async def async_step_zeroconf_setup(
self, user_input: dict[str, Any]
) -> ConfigFlowResult:
"""Handle the direct setup step triggered via zeroconf.""" """Handle the direct setup step triggered via zeroconf."""
if user_input is None: if user_input is None:
return self.async_show_form( return self.async_show_form(
@ -265,7 +266,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
async def _check_unique_and_create_entry( async def _check_unique_and_create_entry(
self, unique_id: str, title: str, data: Mapping[str, Any] self, unique_id: str, title: str, data: Mapping[str, Any]
) -> FlowResult: ) -> ConfigFlowResult:
# Make sure this is the only Elmax integration for this specific panel id. # Make sure this is the only Elmax integration for this specific panel id.
await self.async_set_unique_id(unique_id) await self.async_set_unique_id(unique_id)
self._abort_if_unique_id_configured() self._abort_if_unique_id_configured()
@ -275,7 +276,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
data=data, data=data,
) )
async def async_step_cloud(self, user_input: dict[str, Any]) -> FlowResult: async def async_step_cloud(self, user_input: dict[str, Any]) -> ConfigFlowResult:
"""Handle the cloud setup flow.""" """Handle the cloud setup flow."""
self._selected_mode = CONF_ELMAX_MODE_CLOUD self._selected_mode = CONF_ELMAX_MODE_CLOUD
@ -463,7 +464,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
host: str, host: str,
https_port: int, https_port: int,
http_port: int, http_port: int,
) -> FlowResult | None: ) -> ConfigFlowResult | None:
# Look for another entry with the same PANEL_ID (local or remote). # Look for another entry with the same PANEL_ID (local or remote).
# If there already is a matching panel, take the change to notify the Coordinator # If there already is a matching panel, take the change to notify the Coordinator
# so that it uses the newly discovered IP address. This mitigates the issues # so that it uses the newly discovered IP address. This mitigates the issues
@ -496,7 +497,7 @@ class ElmaxConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_zeroconf( async def async_step_zeroconf(
self, discovery_info: ZeroconfServiceInfo self, discovery_info: ZeroconfServiceInfo
) -> FlowResult: ) -> ConfigFlowResult:
"""Handle device found via zeroconf.""" """Handle device found via zeroconf."""
host = discovery_info.host host = discovery_info.host
https_port = ( https_port = (