Enable strict typing for ambiclimate (#106819)

This commit is contained in:
Marc Mueller 2024-01-02 05:09:22 +01:00 committed by GitHub
parent cc18b9a2d8
commit d93d25a7d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -63,6 +63,7 @@ homeassistant.components.alexa.*
homeassistant.components.alpha_vantage.* homeassistant.components.alpha_vantage.*
homeassistant.components.amazon_polly.* homeassistant.components.amazon_polly.*
homeassistant.components.amberelectric.* homeassistant.components.amberelectric.*
homeassistant.components.ambiclimate.*
homeassistant.components.ambient_station.* homeassistant.components.ambient_station.*
homeassistant.components.amcrest.* homeassistant.components.amcrest.*
homeassistant.components.ampio.* homeassistant.components.ampio.*

View File

@ -6,6 +6,7 @@ import logging
from typing import Any from typing import Any
import ambiclimate import ambiclimate
from ambiclimate import AmbiclimateDevice
import voluptuous as vol import voluptuous as vol
from homeassistant.components.climate import ( from homeassistant.components.climate import (
@ -157,13 +158,13 @@ class AmbiclimateEntity(ClimateEntity):
_attr_has_entity_name = True _attr_has_entity_name = True
_attr_name = None _attr_name = None
def __init__(self, heater, store): def __init__(self, heater: AmbiclimateDevice, store: Store[dict[str, Any]]) -> None:
"""Initialize the thermostat.""" """Initialize the thermostat."""
self._heater = heater self._heater = heater
self._store = store self._store = store
self._attr_unique_id = heater.device_id self._attr_unique_id = heater.device_id
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.unique_id)}, identifiers={(DOMAIN, self.unique_id)}, # type: ignore[arg-type]
manufacturer="Ambiclimate", manufacturer="Ambiclimate",
name=heater.name, name=heater.name,
) )

View File

@ -114,7 +114,7 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
store = Store[dict[str, Any]](self.hass, STORAGE_VERSION, STORAGE_KEY) store = Store[dict[str, Any]](self.hass, STORAGE_VERSION, STORAGE_KEY)
await store.async_save(token_info) await store.async_save(token_info)
return token_info return token_info # type: ignore[no-any-return]
def _generate_view(self) -> None: def _generate_view(self) -> None:
self.hass.http.register_view(AmbiclimateAuthCallbackView()) self.hass.http.register_view(AmbiclimateAuthCallbackView())
@ -132,12 +132,12 @@ class AmbiclimateFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
clientsession, clientsession,
) )
def _cb_url(self): def _cb_url(self) -> str:
return f"{get_url(self.hass, prefer_external=True)}{AUTH_CALLBACK_PATH}" return f"{get_url(self.hass, prefer_external=True)}{AUTH_CALLBACK_PATH}"
async def _get_authorize_url(self): async def _get_authorize_url(self) -> str:
oauth = self._generate_oauth() oauth = self._generate_oauth()
return oauth.get_authorize_url() return oauth.get_authorize_url() # type: ignore[no-any-return]
class AmbiclimateAuthCallbackView(HomeAssistantView): class AmbiclimateAuthCallbackView(HomeAssistantView):

View File

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