Enable strict typing for arcam_fmj (#106837)

This commit is contained in:
Marc Mueller 2024-01-01 21:12:29 +01:00 committed by GitHub
parent 33f8a364ab
commit 73ccd0d310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -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.*

View File

@ -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:

View File

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