diff --git a/.strict-typing b/.strict-typing index 8373e0623f5..8ad4c644110 100644 --- a/.strict-typing +++ b/.strict-typing @@ -223,6 +223,7 @@ homeassistant.components.onewire.* homeassistant.components.open_meteo.* homeassistant.components.openexchangerates.* homeassistant.components.openuv.* +homeassistant.components.otbr.* homeassistant.components.overkiz.* homeassistant.components.peco.* homeassistant.components.persistent_notification.* diff --git a/homeassistant/components/otbr/__init__.py b/homeassistant/components/otbr/__init__.py index 3dee2a8b92e..046643480ca 100644 --- a/homeassistant/components/otbr/__init__.py +++ b/homeassistant/components/otbr/__init__.py @@ -1,8 +1,10 @@ """The Open Thread Border Router integration.""" from __future__ import annotations +from collections.abc import Callable, Coroutine import dataclasses from functools import wraps +from typing import Any, Concatenate, ParamSpec, TypeVar import python_otbr_api @@ -15,12 +17,17 @@ from homeassistant.helpers.typing import ConfigType from . import websocket_api from .const import DOMAIN +_R = TypeVar("_R") +_P = ParamSpec("_P") -def _handle_otbr_error(func): + +def _handle_otbr_error( + func: Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]] +) -> Callable[Concatenate[OTBRData, _P], Coroutine[Any, Any, _R]]: """Handle OTBR errors.""" @wraps(func) - async def _func(self, *args, **kwargs): + async def _func(self: OTBRData, *args: _P.args, **kwargs: _P.kwargs) -> _R: try: return await func(self, *args, **kwargs) except python_otbr_api.OTBRError as exc: diff --git a/homeassistant/components/otbr/manifest.json b/homeassistant/components/otbr/manifest.json index 7247899b80a..796dcd00141 100644 --- a/homeassistant/components/otbr/manifest.json +++ b/homeassistant/components/otbr/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "dependencies": ["thread"], "documentation": "https://www.home-assistant.io/integrations/otbr", - "requirements": ["python-otbr-api==1.0.1"], + "requirements": ["python-otbr-api==1.0.2"], "after_dependencies": ["hassio"], "codeowners": ["@home-assistant/core"], "iot_class": "local_polling", diff --git a/homeassistant/components/otbr/websocket_api.py b/homeassistant/components/otbr/websocket_api.py index 1462bd5d61a..a07819793b1 100644 --- a/homeassistant/components/otbr/websocket_api.py +++ b/homeassistant/components/otbr/websocket_api.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: @callback -def async_setup(hass) -> None: +def async_setup(hass: HomeAssistant) -> None: """Set up the OTBR Websocket API.""" async_register_command(hass, websocket_info) @@ -44,13 +44,10 @@ async def websocket_info( connection.send_error(msg["id"], "get_dataset_failed", str(exc)) return - if dataset: - dataset = dataset.hex() - connection.send_result( msg["id"], { "url": data.url, - "active_dataset_tlvs": dataset, + "active_dataset_tlvs": dataset.hex() if dataset else None, }, ) diff --git a/mypy.ini b/mypy.ini index b60fb346008..7212592dcdd 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1984,6 +1984,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.otbr.*] +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.overkiz.*] check_untyped_defs = true disallow_incomplete_defs = true diff --git a/requirements_all.txt b/requirements_all.txt index 8cfb6cd2445..f9b74f200a5 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2081,7 +2081,7 @@ python-mystrom==1.1.2 python-nest==4.2.0 # homeassistant.components.otbr -python-otbr-api==1.0.1 +python-otbr-api==1.0.2 # homeassistant.components.picnic python-picnic-api==1.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8b95c95f8c9..4ae2de8c488 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1471,7 +1471,7 @@ python-miio==0.5.12 python-nest==4.2.0 # homeassistant.components.otbr -python-otbr-api==1.0.1 +python-otbr-api==1.0.2 # homeassistant.components.picnic python-picnic-api==1.1.0