From 73ccd0d310f4e33b9ac252b97c537ce3139e3358 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 1 Jan 2024 21:12:29 +0100 Subject: [PATCH] Enable strict typing for arcam_fmj (#106837) --- .strict-typing | 1 + homeassistant/components/arcam_fmj/media_player.py | 12 +++++++++--- mypy.ini | 10 ++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.strict-typing b/.strict-typing index 765f429e5e3..8638cacbc22 100644 --- a/.strict-typing +++ b/.strict-typing @@ -78,6 +78,7 @@ homeassistant.components.aprs.* homeassistant.components.aqualogic.* homeassistant.components.aquostv.* homeassistant.components.aranet.* +homeassistant.components.arcam_fmj.* homeassistant.components.arris_tg2492lg.* homeassistant.components.aruba.* homeassistant.components.aseko_pool_live.* diff --git a/homeassistant/components/arcam_fmj/media_player.py b/homeassistant/components/arcam_fmj/media_player.py index 12114ec04b8..7c4ec280101 100644 --- a/homeassistant/components/arcam_fmj/media_player.py +++ b/homeassistant/components/arcam_fmj/media_player.py @@ -1,9 +1,10 @@ """Arcam media player.""" from __future__ import annotations +from collections.abc import Callable, Coroutine import functools import logging -from typing import Any +from typing import Any, ParamSpec, TypeVar from arcam.fmj import ConnectionFailed, SourceCodes from arcam.fmj.state import State @@ -34,6 +35,9 @@ from .const import ( SIGNAL_CLIENT_STOPPED, ) +_R = TypeVar("_R") +_P = ParamSpec("_P") + _LOGGER = logging.getLogger(__name__) @@ -59,11 +63,13 @@ async def async_setup_entry( ) -def convert_exception(func): +def convert_exception( + func: Callable[_P, Coroutine[Any, Any, _R]], +) -> Callable[_P, Coroutine[Any, Any, _R]]: """Return decorator to convert a connection error into a home assistant error.""" @functools.wraps(func) - async def _convert_exception(*args, **kwargs): + async def _convert_exception(*args: _P.args, **kwargs: _P.kwargs) -> _R: try: return await func(*args, **kwargs) except ConnectionFailed as exception: diff --git a/mypy.ini b/mypy.ini index 1c8158066ce..e79f005a6a8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -540,6 +540,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.arcam_fmj.*] +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.arris_tg2492lg.*] check_untyped_defs = true disallow_incomplete_defs = true