diff --git a/homeassistant/components/nws/weather.py b/homeassistant/components/nws/weather.py index 21d9a62bbb0..9ae1f9f7ff9 100644 --- a/homeassistant/components/nws/weather.py +++ b/homeassistant/components/nws/weather.py @@ -4,7 +4,7 @@ from __future__ import annotations from functools import partial from types import MappingProxyType -from typing import TYPE_CHECKING, Any, cast +from typing import TYPE_CHECKING, Any, Literal, cast from homeassistant.components.weather import ( ATTR_CONDITION_CLEAR_NIGHT, @@ -156,6 +156,8 @@ class NWSWeather(CoordinatorWeatherEntity[TimestampDataUpdateCoordinator[None]]) for forecast_type in ("twice_daily", "hourly"): if (coordinator := self.forecast_coordinators[forecast_type]) is None: continue + if TYPE_CHECKING: + forecast_type = cast(Literal["twice_daily", "hourly"], forecast_type) self.unsub_forecast[forecast_type] = coordinator.async_add_listener( partial(self._handle_forecast_update, forecast_type) ) diff --git a/homeassistant/components/recorder/models/state.py b/homeassistant/components/recorder/models/state.py index ca70b856d76..139522a3d20 100644 --- a/homeassistant/components/recorder/models/state.py +++ b/homeassistant/components/recorder/models/state.py @@ -74,7 +74,7 @@ class LazyState(State): def last_changed(self) -> datetime: # type: ignore[override] """Last changed datetime.""" return dt_util.utc_from_timestamp( - self._last_changed_ts or self._last_updated_ts + self._last_changed_ts or self._last_updated_ts # type: ignore[arg-type] ) @cached_property @@ -86,7 +86,7 @@ class LazyState(State): def last_reported(self) -> datetime: # type: ignore[override] """Last reported datetime.""" return dt_util.utc_from_timestamp( - self._last_reported_ts or self._last_updated_ts + self._last_reported_ts or self._last_updated_ts # type: ignore[arg-type] ) @cached_property diff --git a/homeassistant/components/transmission/__init__.py b/homeassistant/components/transmission/__init__.py index d7d6ae4ea0c..681b4438099 100644 --- a/homeassistant/components/transmission/__init__.py +++ b/homeassistant/components/transmission/__init__.py @@ -5,7 +5,7 @@ from __future__ import annotations from functools import partial import logging import re -from typing import Any +from typing import Any, Literal import transmission_rpc from transmission_rpc.error import ( @@ -248,6 +248,7 @@ async def get_api( hass: HomeAssistant, entry: dict[str, Any] ) -> transmission_rpc.Client: """Get Transmission client.""" + protocol: Literal["http", "https"] protocol = "https" if entry[CONF_SSL] else "http" host = entry[CONF_HOST] port = entry[CONF_PORT] diff --git a/homeassistant/util/json.py b/homeassistant/util/json.py index 9a30ae8f104..1479550b615 100644 --- a/homeassistant/util/json.py +++ b/homeassistant/util/json.py @@ -17,13 +17,13 @@ from .file import WriteError # noqa: F401 _SENTINEL = object() _LOGGER = logging.getLogger(__name__) -JsonValueType = ( - dict[str, "JsonValueType"] | list["JsonValueType"] | str | int | float | bool | None +type JsonValueType = ( + dict[str, JsonValueType] | list[JsonValueType] | str | int | float | bool | None ) """Any data that can be returned by the standard JSON deserializing process.""" -JsonArrayType = list[JsonValueType] +type JsonArrayType = list[JsonValueType] """List that can be returned by the standard JSON deserializing process.""" -JsonObjectType = dict[str, JsonValueType] +type JsonObjectType = dict[str, JsonValueType] """Dictionary that can be returned by the standard JSON deserializing process.""" JSON_ENCODE_EXCEPTIONS = (TypeError, ValueError) diff --git a/requirements_test.txt b/requirements_test.txt index 1b1afc24c81..5651a411cb0 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -11,7 +11,7 @@ astroid==3.2.2 coverage==7.5.0 freezegun==1.5.0 mock-open==1.4.0 -mypy-dev==1.11.0a3 +mypy-dev==1.11.0a5 pre-commit==3.7.1 pydantic==1.10.15 pylint==3.2.2