diff --git a/.strict-typing b/.strict-typing index fc6be9aaa8f..5c65e947b91 100644 --- a/.strict-typing +++ b/.strict-typing @@ -61,6 +61,7 @@ homeassistant.components.alert.* homeassistant.components.alexa.* homeassistant.components.alpha_vantage.* homeassistant.components.amazon_polly.* +homeassistant.components.amberelectric.* homeassistant.components.ambient_station.* homeassistant.components.amcrest.* homeassistant.components.ampio.* diff --git a/homeassistant/components/amberelectric/binary_sensor.py b/homeassistant/components/amberelectric/binary_sensor.py index 1931bcbd32c..25a6c2fe267 100644 --- a/homeassistant/components/amberelectric/binary_sensor.py +++ b/homeassistant/components/amberelectric/binary_sensor.py @@ -2,7 +2,6 @@ from __future__ import annotations -from collections.abc import Mapping from typing import Any from homeassistant.components.binary_sensor import ( @@ -45,14 +44,14 @@ class AmberPriceGridSensor( @property def is_on(self) -> bool | None: """Return true if the binary sensor is on.""" - return self.coordinator.data["grid"][self.entity_description.key] + return self.coordinator.data["grid"][self.entity_description.key] # type: ignore[no-any-return] class AmberPriceSpikeBinarySensor(AmberPriceGridSensor): """Sensor to show single grid binary values.""" @property - def icon(self): + def icon(self) -> str: """Return the sensor icon.""" status = self.coordinator.data["grid"]["price_spike"] return PRICE_SPIKE_ICONS[status] @@ -60,10 +59,10 @@ class AmberPriceSpikeBinarySensor(AmberPriceGridSensor): @property def is_on(self) -> bool | None: """Return true if the binary sensor is on.""" - return self.coordinator.data["grid"]["price_spike"] == "spike" + return self.coordinator.data["grid"]["price_spike"] == "spike" # type: ignore[no-any-return] @property - def extra_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> dict[str, Any]: """Return additional pieces of information about the price spike.""" spike_status = self.coordinator.data["grid"]["price_spike"] @@ -80,10 +79,10 @@ async def async_setup_entry( """Set up a config entry.""" coordinator: AmberUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - entities: list = [] price_spike_description = BinarySensorEntityDescription( key="price_spike", name=f"{entry.title} - Price Spike", ) - entities.append(AmberPriceSpikeBinarySensor(coordinator, price_spike_description)) - async_add_entities(entities) + async_add_entities( + [AmberPriceSpikeBinarySensor(coordinator, price_spike_description)] + ) diff --git a/homeassistant/components/amberelectric/config_flow.py b/homeassistant/components/amberelectric/config_flow.py index 0258fdf4cb4..4011f442ee2 100644 --- a/homeassistant/components/amberelectric/config_flow.py +++ b/homeassistant/components/amberelectric/config_flow.py @@ -28,10 +28,10 @@ class AmberElectricConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): def _fetch_sites(self, token: str) -> list[Site] | None: configuration = amberelectric.Configuration(access_token=token) - api = amber_api.AmberApi.create(configuration) + api: amber_api.AmberApi = amber_api.AmberApi.create(configuration) try: - sites = api.get_sites() + sites: list[Site] = api.get_sites() if len(sites) == 0: self._errors[CONF_API_TOKEN] = "no_site" return None diff --git a/homeassistant/components/amberelectric/coordinator.py b/homeassistant/components/amberelectric/coordinator.py index 75cf3fd4360..3e420be2f68 100644 --- a/homeassistant/components/amberelectric/coordinator.py +++ b/homeassistant/components/amberelectric/coordinator.py @@ -30,19 +30,19 @@ def is_forecast(interval: ActualInterval | CurrentInterval | ForecastInterval) - def is_general(interval: ActualInterval | CurrentInterval | ForecastInterval) -> bool: """Return true if the supplied interval is on the general channel.""" - return interval.channel_type == ChannelType.GENERAL + return interval.channel_type == ChannelType.GENERAL # type: ignore[no-any-return] def is_controlled_load( interval: ActualInterval | CurrentInterval | ForecastInterval, ) -> bool: """Return true if the supplied interval is on the controlled load channel.""" - return interval.channel_type == ChannelType.CONTROLLED_LOAD + return interval.channel_type == ChannelType.CONTROLLED_LOAD # type: ignore[no-any-return] def is_feed_in(interval: ActualInterval | CurrentInterval | ForecastInterval) -> bool: """Return true if the supplied interval is on the feed in channel.""" - return interval.channel_type == ChannelType.FEED_IN + return interval.channel_type == ChannelType.FEED_IN # type: ignore[no-any-return] def normalize_descriptor(descriptor: Descriptor) -> str | None: diff --git a/homeassistant/components/amberelectric/sensor.py b/homeassistant/components/amberelectric/sensor.py index 4a6d1a6ea18..97ecc103661 100644 --- a/homeassistant/components/amberelectric/sensor.py +++ b/homeassistant/components/amberelectric/sensor.py @@ -7,7 +7,6 @@ from __future__ import annotations -from collections.abc import Mapping from typing import Any from amberelectric.model.channel import ChannelType @@ -86,7 +85,7 @@ class AmberPriceSensor(AmberSensor): return format_cents_to_dollars(interval.per_kwh) @property - def extra_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> dict[str, Any] | None: """Return additional pieces of information about the price.""" interval = self.coordinator.data[self.entity_description.key][self.channel_type] @@ -133,7 +132,7 @@ class AmberForecastSensor(AmberSensor): return format_cents_to_dollars(interval.per_kwh) @property - def extra_state_attributes(self) -> Mapping[str, Any] | None: + def extra_state_attributes(self) -> dict[str, Any] | None: """Return additional pieces of information about the price.""" intervals = self.coordinator.data[self.entity_description.key].get( self.channel_type @@ -177,7 +176,7 @@ class AmberPriceDescriptorSensor(AmberSensor): @property def native_value(self) -> str | None: """Return the current price descriptor.""" - return self.coordinator.data[self.entity_description.key][self.channel_type] + return self.coordinator.data[self.entity_description.key][self.channel_type] # type: ignore[no-any-return] class AmberGridSensor(CoordinatorEntity[AmberUpdateCoordinator], SensorEntity): @@ -199,7 +198,7 @@ class AmberGridSensor(CoordinatorEntity[AmberUpdateCoordinator], SensorEntity): @property def native_value(self) -> str | None: """Return the value of the sensor.""" - return self.coordinator.data["grid"][self.entity_description.key] + return self.coordinator.data["grid"][self.entity_description.key] # type: ignore[no-any-return] async def async_setup_entry( @@ -213,7 +212,7 @@ async def async_setup_entry( current: dict[str, CurrentInterval] = coordinator.data["current"] forecasts: dict[str, list[ForecastInterval]] = coordinator.data["forecasts"] - entities: list = [] + entities: list[SensorEntity] = [] for channel_type in current: description = SensorEntityDescription( key="current", diff --git a/mypy.ini b/mypy.ini index 958396707fc..c0e87ebb14b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -370,6 +370,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.amberelectric.*] +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.*] check_untyped_defs = true disallow_incomplete_defs = true