fix(types): resolve Pyright type errors

- coordinator/core.py: Fix return type for _get_threshold_percentages()
- coordinator/data_transformation.py: Add type ignore for cached data return
- sensor/core.py: Initialize _state_info with required unrecorded_attributes
This commit is contained in:
Julian Pawlowski 2025-12-22 23:22:02 +00:00
parent 4158e7b1fd
commit 49b8a018e7
3 changed files with 4 additions and 3 deletions

View file

@ -739,7 +739,7 @@ class TibberPricesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
return {}
return self._transform_data(self._cached_price_data)
def _get_threshold_percentages(self) -> dict[str, int]:
def _get_threshold_percentages(self) -> dict[str, int | float]:
"""Get threshold percentages from config options."""
return self._data_transformer.get_threshold_percentages()

View file

@ -223,7 +223,8 @@ class TibberPricesDataTransformer:
if not should_retransform and has_cache:
self._log("debug", "Using cached transformed data (no transformation needed)")
return self._cached_transformed_data
# has_cache ensures _cached_transformed_data is not None
return self._cached_transformed_data # type: ignore[return-value]
self._log("debug", "Transforming price data (enrichment + period calculation)")

View file

@ -221,7 +221,7 @@ class TibberPricesSensor(TibberPricesEntity, RestoreSensor):
)
# Modify _state_info to add dynamic exclusion
if self._state_info is None:
self._state_info = {}
self._state_info = {"unrecorded_attributes": frozenset()}
current_unrecorded = self._state_info.get("unrecorded_attributes", frozenset())
# State shows median → exclude price_median from attributes
# State shows mean → exclude price_mean from attributes