diff --git a/.strict-typing b/.strict-typing index 2adadffea49..97e3f577849 100644 --- a/.strict-typing +++ b/.strict-typing @@ -361,6 +361,7 @@ homeassistant.components.webostv.* homeassistant.components.websocket_api.* homeassistant.components.wemo.* homeassistant.components.whois.* +homeassistant.components.withings.* homeassistant.components.wiz.* homeassistant.components.wled.* homeassistant.components.worldclock.* diff --git a/homeassistant/components/withings/__init__.py b/homeassistant/components/withings/__init__.py index 9084d80e5c5..ba58ee650be 100644 --- a/homeassistant/components/withings/__init__.py +++ b/homeassistant/components/withings/__init__.py @@ -8,7 +8,7 @@ import asyncio from collections.abc import Awaitable, Callable import contextlib from datetime import timedelta -from typing import Any +from typing import TYPE_CHECKING, Any from aiohttp.hdrs import METH_POST from aiohttp.web import Request, Response @@ -148,7 +148,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def _refresh_token() -> str: await oauth_session.async_ensure_token_valid() - return oauth_session.token[CONF_ACCESS_TOKEN] + token = oauth_session.token[CONF_ACCESS_TOKEN] + if TYPE_CHECKING: + assert isinstance(token, str) + return token client.refresh_token_function = _refresh_token coordinators: dict[str, WithingsDataUpdateCoordinator] = { diff --git a/mypy.ini b/mypy.ini index 93fe5326e98..43ec39ebc56 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3373,6 +3373,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.withings.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.wiz.*] check_untyped_defs = true disallow_incomplete_defs = true