diff --git a/.strict-typing b/.strict-typing index b4abed22bf8..a976deed8c1 100644 --- a/.strict-typing +++ b/.strict-typing @@ -116,6 +116,7 @@ homeassistant.components.clickatell.* homeassistant.components.clicksend.* homeassistant.components.climate.* homeassistant.components.cloud.* +homeassistant.components.command_line.* homeassistant.components.configurator.* homeassistant.components.cover.* homeassistant.components.cpuspeed.* diff --git a/homeassistant/components/command_line/__init__.py b/homeassistant/components/command_line/__init__.py index e1a051cea33..ba4292b5a65 100644 --- a/homeassistant/components/command_line/__init__.py +++ b/homeassistant/components/command_line/__init__.py @@ -200,7 +200,7 @@ async def async_load_platforms( load_coroutines: list[Coroutine[Any, Any, None]] = [] platforms: list[Platform] = [] - reload_configs: list[tuple] = [] + reload_configs: list[tuple[Platform, dict[str, Any]]] = [] for platform_config in command_line_config: for platform, _config in platform_config.items(): if (mapped_platform := PLATFORM_MAPPING[platform]) not in platforms: diff --git a/homeassistant/components/command_line/binary_sensor.py b/homeassistant/components/command_line/binary_sensor.py index f559812207f..31259ddf909 100644 --- a/homeassistant/components/command_line/binary_sensor.py +++ b/homeassistant/components/command_line/binary_sensor.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from datetime import timedelta +from datetime import datetime, timedelta from typing import cast from homeassistant.components.binary_sensor import ( @@ -115,7 +115,7 @@ class CommandBinarySensor(ManualTriggerEntity, BinarySensorEntity): async def async_added_to_hass(self) -> None: """Call when entity about to be added to hass.""" await super().async_added_to_hass() - await self._update_entity_state(None) + await self._update_entity_state() self.async_on_remove( async_track_time_interval( self.hass, @@ -126,7 +126,7 @@ class CommandBinarySensor(ManualTriggerEntity, BinarySensorEntity): ), ) - async def _update_entity_state(self, now) -> None: + async def _update_entity_state(self, now: datetime | None = None) -> None: """Update the state of the entity.""" if self._process_updates is None: self._process_updates = asyncio.Lock() diff --git a/homeassistant/components/command_line/cover.py b/homeassistant/components/command_line/cover.py index 6b413712ed7..93c007297ea 100644 --- a/homeassistant/components/command_line/cover.py +++ b/homeassistant/components/command_line/cover.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from datetime import timedelta +from datetime import datetime, timedelta from typing import TYPE_CHECKING, Any, cast from homeassistant.components.cover import CoverEntity @@ -147,7 +147,7 @@ class CommandCover(ManualTriggerEntity, CoverEntity): if TYPE_CHECKING: return None - async def _update_entity_state(self, now) -> None: + async def _update_entity_state(self, now: datetime | None = None) -> None: """Update the state of the entity.""" if self._process_updates is None: self._process_updates = asyncio.Lock() @@ -186,14 +186,14 @@ class CommandCover(ManualTriggerEntity, CoverEntity): async def async_open_cover(self, **kwargs: Any) -> None: """Open the cover.""" await self.hass.async_add_executor_job(self._move_cover, self._command_open) - await self._update_entity_state(None) + await self._update_entity_state() async def async_close_cover(self, **kwargs: Any) -> None: """Close the cover.""" await self.hass.async_add_executor_job(self._move_cover, self._command_close) - await self._update_entity_state(None) + await self._update_entity_state() async def async_stop_cover(self, **kwargs: Any) -> None: """Stop the cover.""" await self.hass.async_add_executor_job(self._move_cover, self._command_stop) - await self._update_entity_state(None) + await self._update_entity_state() diff --git a/homeassistant/components/command_line/sensor.py b/homeassistant/components/command_line/sensor.py index 99390e77357..c1d60b9d2fd 100644 --- a/homeassistant/components/command_line/sensor.py +++ b/homeassistant/components/command_line/sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio from collections.abc import Mapping -from datetime import timedelta +from datetime import datetime, timedelta import json from typing import Any, cast @@ -108,7 +108,7 @@ class CommandSensor(ManualTriggerSensorEntity): """Initialize the sensor.""" super().__init__(self.hass, config) self.data = data - self._attr_extra_state_attributes = {} + self._attr_extra_state_attributes: dict[str, Any] = {} self._json_attributes = json_attributes self._attr_native_value = None self._value_template = value_template @@ -118,12 +118,12 @@ class CommandSensor(ManualTriggerSensorEntity): @property def extra_state_attributes(self) -> dict[str, Any]: """Return extra state attributes.""" - return cast(dict, self._attr_extra_state_attributes) + return self._attr_extra_state_attributes async def async_added_to_hass(self) -> None: """Call when entity about to be added to hass.""" await super().async_added_to_hass() - await self._update_entity_state(None) + await self._update_entity_state() self.async_on_remove( async_track_time_interval( self.hass, @@ -134,7 +134,7 @@ class CommandSensor(ManualTriggerSensorEntity): ), ) - async def _update_entity_state(self, now) -> None: + async def _update_entity_state(self, now: datetime | None = None) -> None: """Update the state of the entity.""" if self._process_updates is None: self._process_updates = asyncio.Lock() diff --git a/homeassistant/components/command_line/switch.py b/homeassistant/components/command_line/switch.py index 8d30de310ef..0af6163312c 100644 --- a/homeassistant/components/command_line/switch.py +++ b/homeassistant/components/command_line/switch.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from datetime import timedelta +from datetime import datetime, timedelta from typing import TYPE_CHECKING, Any, cast from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity @@ -155,7 +155,7 @@ class CommandSwitch(ManualTriggerEntity, SwitchEntity): if TYPE_CHECKING: return None - async def _update_entity_state(self, now) -> None: + async def _update_entity_state(self, now: datetime | None = None) -> None: """Update the state of the entity.""" if self._process_updates is None: self._process_updates = asyncio.Lock() @@ -197,11 +197,11 @@ class CommandSwitch(ManualTriggerEntity, SwitchEntity): if await self._switch(self._command_on) and not self._command_state: self._attr_is_on = True self.async_schedule_update_ha_state() - await self._update_entity_state(None) + await self._update_entity_state() async def async_turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" if await self._switch(self._command_off) and not self._command_state: self._attr_is_on = False self.async_schedule_update_ha_state() - await self._update_entity_state(None) + await self._update_entity_state() diff --git a/mypy.ini b/mypy.ini index 9fd8f6a1305..7a2e16c37ed 100644 --- a/mypy.ini +++ b/mypy.ini @@ -920,6 +920,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.command_line.*] +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.configurator.*] check_untyped_defs = true disallow_incomplete_defs = true