Improve type hints in tomorrowio weather (#163246)

This commit is contained in:
epenet
2026-02-17 11:07:48 +01:00
committed by GitHub
parent 6322185206
commit 487e2f8ccc
2 changed files with 11 additions and 9 deletions

View File

@@ -2,6 +2,8 @@
from __future__ import annotations
from typing import Any
from pytomorrowio.const import CURRENT
from homeassistant.config_entries import ConfigEntry
@@ -36,7 +38,7 @@ class TomorrowioEntity(CoordinatorEntity[TomorrowioDataUpdateCoordinator]):
entry_type=DeviceEntryType.SERVICE,
)
def _get_current_property(self, property_name: str) -> int | str | float | None:
def _get_current_property(self, property_name: str) -> Any | None:
"""Get property from current conditions.
Used for V4 API.

View File

@@ -175,37 +175,37 @@ class TomorrowioWeatherEntity(TomorrowioEntity, SingleCoordinatorWeatherEntity):
return CONDITIONS[condition]
@property
def native_temperature(self):
def native_temperature(self) -> float | None:
"""Return the platform temperature."""
return self._get_current_property(TMRW_ATTR_TEMPERATURE)
@property
def native_pressure(self):
def native_pressure(self) -> float | None:
"""Return the raw pressure."""
return self._get_current_property(TMRW_ATTR_PRESSURE)
@property
def humidity(self):
def humidity(self) -> float | None:
"""Return the humidity."""
return self._get_current_property(TMRW_ATTR_HUMIDITY)
@property
def native_wind_speed(self):
def native_wind_speed(self) -> float | None:
"""Return the raw wind speed."""
return self._get_current_property(TMRW_ATTR_WIND_SPEED)
@property
def wind_bearing(self):
def wind_bearing(self) -> float | None:
"""Return the wind bearing."""
return self._get_current_property(TMRW_ATTR_WIND_DIRECTION)
@property
def ozone(self):
def ozone(self) -> float | None:
"""Return the O3 (ozone) level."""
return self._get_current_property(TMRW_ATTR_OZONE)
@property
def condition(self):
def condition(self) -> str | None:
"""Return the condition."""
return self._translate_condition(
self._get_current_property(TMRW_ATTR_CONDITION),
@@ -213,7 +213,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, SingleCoordinatorWeatherEntity):
)
@property
def native_visibility(self):
def native_visibility(self) -> float | None:
"""Return the raw visibility."""
return self._get_current_property(TMRW_ATTR_VISIBILITY)