Enable strict typing for Climate component (#99301)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
James Smith 2023-09-06 08:55:41 -07:00 committed by GitHub
parent 8bfdc5d3d9
commit f24c4ceab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 6 deletions

View File

@ -88,6 +88,7 @@ homeassistant.components.camera.*
homeassistant.components.canary.*
homeassistant.components.clickatell.*
homeassistant.components.clicksend.*
homeassistant.components.climate.*
homeassistant.components.cloud.*
homeassistant.components.configurator.*
homeassistant.components.cover.*

View File

@ -242,8 +242,9 @@ class ClimateEntity(Entity):
hvac_mode = self.hvac_mode
if hvac_mode is None:
return None
# Support hvac_mode as string for custom integration backwards compatibility
if not isinstance(hvac_mode, HVACMode):
return HVACMode(hvac_mode).value
return HVACMode(hvac_mode).value # type: ignore[unreachable]
return hvac_mode.value
@property
@ -458,11 +459,11 @@ class ClimateEntity(Entity):
"""
return self._attr_swing_modes
def set_temperature(self, **kwargs) -> None:
def set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
raise NotImplementedError()
async def async_set_temperature(self, **kwargs) -> None:
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""
await self.hass.async_add_executor_job(
ft.partial(self.set_temperature, **kwargs)

View File

@ -92,9 +92,9 @@ def async_condition_from_config(
return False
if config[CONF_TYPE] == "is_hvac_mode":
return state.state == config[const.ATTR_HVAC_MODE]
return bool(state.state == config[const.ATTR_HVAC_MODE])
return (
return bool(
state.attributes.get(const.ATTR_PRESET_MODE)
== config[const.ATTR_PRESET_MODE]
)

View File

@ -38,7 +38,9 @@ async def _async_reproduce_states(
) -> None:
"""Reproduce component states."""
async def call_service(service: str, keys: Iterable, data=None):
async def call_service(
service: str, keys: Iterable, data: dict[str, Any] | None = None
) -> None:
"""Call service with set of attributes given."""
data = data or {}
data["entity_id"] = state.entity_id

View File

@ -641,6 +641,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.climate.*]
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.cloud.*]
check_untyped_defs = true
disallow_incomplete_defs = true