Improve type hints in weather (#78346)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
epenet 2022-09-14 11:15:47 +02:00 committed by GitHub
parent b87cd926e7
commit dce2569389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,8 +45,6 @@ from homeassistant.util import (
temperature as temperature_util,
)
# mypy: allow-untyped-defs, no-check-untyped-defs
_LOGGER = logging.getLogger(__name__)
ATTR_CONDITION_CLASS = "condition_class"
@ -626,9 +624,9 @@ class WeatherEntity(Entity):
@final
@property
def state_attributes(self):
def state_attributes(self) -> dict[str, Any]:
"""Return the state attributes, converted from native units to user-configured units."""
data = {}
data: dict[str, Any] = {}
precision = self.precision
@ -705,9 +703,9 @@ class WeatherEntity(Entity):
data[ATTR_WEATHER_PRECIPITATION_UNIT] = self._precipitation_unit
if self.forecast is not None:
forecast = []
for forecast_entry in self.forecast:
forecast_entry = dict(forecast_entry)
forecast: list[dict[str, Any]] = []
for existing_forecast_entry in self.forecast:
forecast_entry: dict[str, Any] = dict(existing_forecast_entry)
temperature = forecast_entry.pop(
ATTR_FORECAST_NATIVE_TEMP, forecast_entry.get(ATTR_FORECAST_TEMP)