Enable strict typing in Tankerkoenig (#149535)

This commit is contained in:
Michael 2025-07-27 22:48:15 +02:00 committed by GitHub
parent 622cce03a1
commit e30d405625
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 4 deletions

View File

@ -501,6 +501,7 @@ homeassistant.components.tag.*
homeassistant.components.tailscale.* homeassistant.components.tailscale.*
homeassistant.components.tailwind.* homeassistant.components.tailwind.*
homeassistant.components.tami4.* homeassistant.components.tami4.*
homeassistant.components.tankerkoenig.*
homeassistant.components.tautulli.* homeassistant.components.tautulli.*
homeassistant.components.tcp.* homeassistant.components.tcp.*
homeassistant.components.technove.* homeassistant.components.technove.*

View File

@ -15,7 +15,6 @@ from aiotankerkoenig import (
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ( from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult, ConfigFlowResult,
OptionsFlowWithReload, OptionsFlowWithReload,
@ -40,6 +39,7 @@ from homeassistant.helpers.selector import (
) )
from .const import CONF_STATIONS, DEFAULT_RADIUS, DOMAIN from .const import CONF_STATIONS, DEFAULT_RADIUS, DOMAIN
from .coordinator import TankerkoenigConfigEntry
async def async_get_nearby_stations( async def async_get_nearby_stations(
@ -71,7 +71,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: ConfigEntry, config_entry: TankerkoenigConfigEntry,
) -> OptionsFlowHandler: ) -> OptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler() return OptionsFlowHandler()

View File

@ -110,7 +110,14 @@ class FuelPriceSensor(TankerkoenigCoordinatorEntity, SensorEntity):
self._attr_extra_state_attributes = attrs self._attr_extra_state_attributes = attrs
@property @property
def native_value(self) -> float: def native_value(self) -> float | None:
"""Return the current price for the fuel type.""" """Return the current price for the fuel type."""
info = self.coordinator.data[self._station_id] info = self.coordinator.data[self._station_id]
return getattr(info, self._fuel_type) result = None
if self._fuel_type is GasType.E10:
result = info.e10
elif self._fuel_type is GasType.E5:
result = info.e5
else:
result = info.diesel
return result

10
mypy.ini generated
View File

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