From 06fa3068219c7936337da8f20baee6bf6bf05757 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 2 Jan 2024 13:29:07 +0100 Subject: [PATCH] Mark humidifier entity component as strictly typed (#106721) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> --- .strict-typing | 1 + homeassistant/components/humidifier/__init__.py | 2 +- homeassistant/components/humidifier/reproduce_state.py | 5 ++--- mypy.ini | 10 ++++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.strict-typing b/.strict-typing index ff0ecd1c3ae..db69d828003 100644 --- a/.strict-typing +++ b/.strict-typing @@ -202,6 +202,7 @@ homeassistant.components.homekit_controller.utils homeassistant.components.homewizard.* homeassistant.components.http.* homeassistant.components.huawei_lte.* +homeassistant.components.humidifier.* homeassistant.components.hydrawise.* homeassistant.components.hyperion.* homeassistant.components.ibeacon.* diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index 75d4f0fd225..ea6e8972cc6 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -91,7 +91,7 @@ __dir__ = partial(dir_with_deprecated_constants, module_globals=globals()) @bind_hass -def is_on(hass, entity_id): +def is_on(hass: HomeAssistant, entity_id: str) -> bool: """Return if the humidifier is on based on the statemachine. Async friendly. diff --git a/homeassistant/components/humidifier/reproduce_state.py b/homeassistant/components/humidifier/reproduce_state.py index b0e9a29cacc..be4f1afbeb9 100644 --- a/homeassistant/components/humidifier/reproduce_state.py +++ b/homeassistant/components/humidifier/reproduce_state.py @@ -32,10 +32,9 @@ async def _async_reproduce_states( _LOGGER.warning("Unable to find entity %s", state.entity_id) return - async def call_service(service: str, keys: Iterable, data=None): + async def call_service(service: str, keys: Iterable[str]) -> None: """Call service with set of attributes given.""" - data = data or {} - data["entity_id"] = state.entity_id + data = {"entity_id": state.entity_id} for key in keys: if key in state.attributes: data[key] = state.attributes[key] diff --git a/mypy.ini b/mypy.ini index f1c2cfa2cf3..9ffbac47b25 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1781,6 +1781,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.humidifier.*] +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.hydrawise.*] check_untyped_defs = true disallow_incomplete_defs = true