diff --git a/homeassistant/components/almond/__init__.py b/homeassistant/components/almond/__init__.py index 5d3b5a86942..6a5449e3d51 100644 --- a/homeassistant/components/almond/__init__.py +++ b/homeassistant/components/almond/__init__.py @@ -5,6 +5,7 @@ import asyncio from datetime import timedelta import logging import time +from typing import Optional, cast from aiohttp import ClientError, ClientSession import async_timeout @@ -166,7 +167,7 @@ async def _configure_almond_for_ha( _LOGGER.debug("Configuring Almond to connect to Home Assistant at %s", hass_url) store = storage.Store(hass, STORAGE_VERSION, STORAGE_KEY) - data = await store.async_load() + data = cast(Optional[dict], await store.async_load()) if data is None: data = {} @@ -204,7 +205,7 @@ async def _configure_almond_for_ha( ) except (asyncio.TimeoutError, ClientError) as err: if isinstance(err, asyncio.TimeoutError): - msg = "Request timeout" + msg: str | ClientError = "Request timeout" else: msg = err _LOGGER.warning("Unable to configure Almond: %s", msg) diff --git a/homeassistant/components/almond/config_flow.py b/homeassistant/components/almond/config_flow.py index d6084569ff7..b7b56f93864 100644 --- a/homeassistant/components/almond/config_flow.py +++ b/homeassistant/components/almond/config_flow.py @@ -1,6 +1,9 @@ """Config flow to connect with Home Assistant.""" +from __future__ import annotations + import asyncio import logging +from typing import Any from aiohttp import ClientError import async_timeout @@ -9,6 +12,7 @@ import voluptuous as vol from yarl import URL from homeassistant import config_entries, core, data_entry_flow +from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import aiohttp_client, config_entry_oauth2_flow from .const import DOMAIN as ALMOND_DOMAIN, TYPE_LOCAL, TYPE_OAUTH2 @@ -64,7 +68,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler): return result - async def async_oauth_create_entry(self, data: dict) -> dict: + async def async_oauth_create_entry(self, data: dict) -> FlowResult: """Create an entry for the flow. Ok to override if you want to fetch extra info or even add another step. @@ -73,7 +77,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler): data["host"] = self.host return self.async_create_entry(title=self.flow_impl.name, data=data) - async def async_step_import(self, user_input: dict = None) -> dict: + async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult: """Import data.""" # Only allow 1 instance. if self._async_current_entries(): diff --git a/mypy.ini b/mypy.ini index 37007884be2..69b27cd1093 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1265,9 +1265,6 @@ no_implicit_optional = false warn_return_any = false warn_unreachable = false -[mypy-homeassistant.components.almond.*] -ignore_errors = true - [mypy-homeassistant.components.awair.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 2015b9983c7..b3968bc58c5 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -14,7 +14,6 @@ from .model import Config, Integration # remove your component from this list to enable type checks. # Do your best to not add anything new here. IGNORED_MODULES: Final[list[str]] = [ - "homeassistant.components.almond.*", "homeassistant.components.awair.*", "homeassistant.components.azure_event_hub.*", "homeassistant.components.blueprint.*", diff --git a/tests/components/almond/test_config_flow.py b/tests/components/almond/test_config_flow.py index 892abaa9650..b5a3d90fbdb 100644 --- a/tests/components/almond/test_config_flow.py +++ b/tests/components/almond/test_config_flow.py @@ -82,7 +82,7 @@ async def test_abort_if_existing_entry(hass): assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "single_instance_allowed" - result = await flow.async_step_import() + result = await flow.async_step_import({}) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result["reason"] == "single_instance_allowed"