mirror of
https://github.com/home-assistant/core.git
synced 2026-04-01 16:09:02 +01:00
Update mypy to 1.20.0 (#167000)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from adext import AdExt
|
||||
from alarmdecoder.devices import SerialDevice, SocketDevice
|
||||
from alarmdecoder.devices import Device, SerialDevice, SocketDevice
|
||||
from alarmdecoder.util import NoDeviceError
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -102,16 +102,21 @@ class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self._async_current_entries(), user_input, self.protocol
|
||||
):
|
||||
return self.async_abort(reason="already_configured")
|
||||
connection = {}
|
||||
connection: dict[str, Any] = {}
|
||||
baud = None
|
||||
device: Device
|
||||
if self.protocol == PROTOCOL_SOCKET:
|
||||
host = connection[CONF_HOST] = user_input[CONF_HOST]
|
||||
port = connection[CONF_PORT] = user_input[CONF_PORT]
|
||||
title = f"{host}:{port}"
|
||||
host = connection[CONF_HOST] = cast(str, user_input[CONF_HOST])
|
||||
port = connection[CONF_PORT] = cast(int, user_input[CONF_PORT])
|
||||
title: str = f"{host}:{port}"
|
||||
device = SocketDevice(interface=(host, port))
|
||||
if self.protocol == PROTOCOL_SERIAL:
|
||||
path = connection[CONF_DEVICE_PATH] = user_input[CONF_DEVICE_PATH]
|
||||
baud = connection[CONF_DEVICE_BAUD] = user_input[CONF_DEVICE_BAUD]
|
||||
path = connection[CONF_DEVICE_PATH] = cast(
|
||||
str, user_input[CONF_DEVICE_PATH]
|
||||
)
|
||||
baud = connection[CONF_DEVICE_BAUD] = cast(
|
||||
int, user_input[CONF_DEVICE_BAUD]
|
||||
)
|
||||
title = path
|
||||
device = SerialDevice(interface=path)
|
||||
|
||||
@@ -132,6 +137,7 @@ class AlarmDecoderFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
_LOGGER.exception("Unexpected exception during AlarmDecoder setup")
|
||||
errors["base"] = "unknown"
|
||||
|
||||
schema: vol.Schema
|
||||
if self.protocol == PROTOCOL_SOCKET:
|
||||
schema = vol.Schema(
|
||||
{
|
||||
|
||||
@@ -210,7 +210,7 @@ def websocket_update_entity(
|
||||
)
|
||||
return
|
||||
|
||||
changes = {}
|
||||
changes: dict[str, Any] = {}
|
||||
|
||||
for key in (
|
||||
"area_id",
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from devolo_home_control_api.devices.zwave import Zwave
|
||||
from devolo_home_control_api.homecontrol import HomeControl
|
||||
|
||||
@@ -188,6 +190,8 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity):
|
||||
def sync_callback(self, message: tuple) -> None:
|
||||
"""Update the consumption sensor state."""
|
||||
if message[0] == self._attr_unique_id:
|
||||
if TYPE_CHECKING:
|
||||
assert self._attr_unique_id is not None
|
||||
self._value = getattr(
|
||||
self._device_instance.consumption_property[self._attr_unique_id],
|
||||
self._sensor_type,
|
||||
|
||||
@@ -25,7 +25,7 @@ def _fix_device_registry_identifiers(
|
||||
if old_identifier not in device_entry.identifiers: # type: ignore[comparison-overlap]
|
||||
continue
|
||||
new_identifiers = device_entry.identifiers.copy()
|
||||
new_identifiers.discard(old_identifier) # type: ignore[arg-type]
|
||||
new_identifiers.discard(old_identifier)
|
||||
new_identifiers.add((DOMAIN, entry.data["station"]))
|
||||
device_registry.async_update_device(
|
||||
device_entry.id, new_identifiers=new_identifiers
|
||||
|
||||
@@ -273,7 +273,7 @@ class ElevenLabsTTSEntity(TextToSpeechEntity):
|
||||
continue
|
||||
|
||||
# Build kwargs common to both modes
|
||||
kwargs = base_stream_params | {
|
||||
kwargs: dict[str, Any] = base_stream_params | {
|
||||
"text": text,
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ElkM1ConfigEntry) -> boo
|
||||
|
||||
elk_temp_unit = elk.panel.temperature_units
|
||||
if elk_temp_unit == "C":
|
||||
temperature_unit = UnitOfTemperature.CELSIUS
|
||||
temperature_unit = UnitOfTemperature.CELSIUS # type: ignore[unreachable]
|
||||
else:
|
||||
temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||
config["temperature_unit"] = temperature_unit
|
||||
|
||||
@@ -979,7 +979,7 @@ class HomeKit:
|
||||
for entry in dev_reg.devices.get_devices_for_config_entry_id(self._entry_id)
|
||||
if (
|
||||
identifier not in entry.identifiers # type: ignore[comparison-overlap]
|
||||
or connection not in entry.connections
|
||||
or connection not in entry.connections # type: ignore[unreachable]
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -97,7 +97,8 @@ SENSOR_TYPES: dict[str, LidarrSensorEntityDescription[Any]] = {
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
entity_registry_enabled_default=False,
|
||||
attributes_fn=lambda data: {
|
||||
album.title: album.artist.artistName for album in data.records
|
||||
album.title: album.artist.artistName # type: ignore[misc]
|
||||
for album in data.records
|
||||
},
|
||||
),
|
||||
"albums": LidarrSensorEntityDescription[int](
|
||||
|
||||
@@ -122,7 +122,7 @@ class ChannelMutingCoordinator(DataUpdateCoordinator[ChannelMutingData]):
|
||||
"""Send muting command for a channel."""
|
||||
self._desired[channel] = param
|
||||
message_data: ChannelMutingDesired = self.data | self._desired
|
||||
message = command.ChannelMuting(**message_data) # type: ignore[misc]
|
||||
message = command.ChannelMuting(**message_data)
|
||||
await self.manager.write(message)
|
||||
|
||||
async def _update_callback(self, message: Status) -> None:
|
||||
|
||||
@@ -276,7 +276,7 @@ def format_upcoming(
|
||||
|
||||
for episode in calendar:
|
||||
# Create a unique key combining series title and episode identifier
|
||||
series_title = episode.series.title if hasattr(episode, "series") else "Unknown"
|
||||
series_title = episode.series.title if hasattr(episode, "series") else "Unknown" # type: ignore[misc]
|
||||
identifier = f"S{episode.seasonNumber:02d}E{episode.episodeNumber:02d}"
|
||||
key = f"{series_title} {identifier}"
|
||||
episodes[key] = format_upcoming_item(episode, base_url)
|
||||
@@ -324,7 +324,7 @@ def format_wanted(
|
||||
for item in wanted.records:
|
||||
# Create a unique key combining series title and episode identifier
|
||||
series_title = (
|
||||
item.series.title if hasattr(item, "series") and item.series else "Unknown"
|
||||
item.series.title if hasattr(item, "series") and item.series else "Unknown" # type: ignore[misc]
|
||||
)
|
||||
identifier = f"S{item.seasonNumber:02d}E{item.episodeNumber:02d}"
|
||||
key = f"{series_title} {identifier}"
|
||||
|
||||
@@ -65,9 +65,9 @@ def get_queue_attr(queue: SonarrQueue) -> dict[str, str]:
|
||||
remaining = 1 if item.size == 0 else item.sizeleft / item.size
|
||||
remaining_pct = 100 * (1 - remaining)
|
||||
identifier = (
|
||||
f"S{item.episode.seasonNumber:02d}E{item.episode.episodeNumber:02d}"
|
||||
f"S{item.episode.seasonNumber:02d}E{item.episode.episodeNumber:02d}" # type: ignore[misc]
|
||||
)
|
||||
attrs[f"{item.series.title} {identifier}"] = f"{remaining_pct:.2f}%"
|
||||
attrs[f"{item.series.title} {identifier}"] = f"{remaining_pct:.2f}%" # type: ignore[misc]
|
||||
return attrs
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ def get_wanted_attr(wanted: SonarrWantedMissing) -> dict[str, str]:
|
||||
for item in wanted.records:
|
||||
identifier = f"S{item.seasonNumber:02d}E{item.episodeNumber:02d}"
|
||||
|
||||
name = f"{item.series.title} {identifier}"
|
||||
name = f"{item.series.title} {identifier}" # type: ignore[misc]
|
||||
attrs[name] = dt_util.as_local(
|
||||
item.airDateUtc.replace(tzinfo=dt_util.UTC)
|
||||
).isoformat()
|
||||
@@ -126,7 +126,8 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
translation_key="upcoming",
|
||||
value_fn=len,
|
||||
attributes_fn=lambda data: {
|
||||
e.series.title: f"S{e.seasonNumber:02d}E{e.episodeNumber:02d}" for e in data
|
||||
e.series.title: f"S{e.seasonNumber:02d}E{e.episodeNumber:02d}" # type: ignore[misc]
|
||||
for e in data
|
||||
},
|
||||
),
|
||||
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
||||
|
||||
@@ -526,7 +526,7 @@ class _ComponentSet(set[str]):
|
||||
self._top_level_components.remove(value)
|
||||
return super().remove(value)
|
||||
|
||||
def discard(self, value: str) -> None:
|
||||
def discard(self, value: object) -> None:
|
||||
"""Remove a component from the store."""
|
||||
raise NotImplementedError("_ComponentSet does not support discard, use remove")
|
||||
|
||||
|
||||
1
mypy.ini
generated
1
mypy.ini
generated
@@ -14,7 +14,6 @@ strict_bytes = true
|
||||
no_implicit_optional = true
|
||||
warn_incomplete_stub = true
|
||||
warn_redundant_casts = true
|
||||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
enable_error_code = deprecated, ignore-without-code, redundant-self, truthy-iterable
|
||||
disable_error_code = annotation-unchecked, import-not-found, import-untyped
|
||||
|
||||
@@ -11,10 +11,10 @@ astroid==4.0.4
|
||||
coverage==7.10.6
|
||||
freezegun==1.5.2
|
||||
# librt is an internal mypy dependency
|
||||
librt==0.7.3
|
||||
librt==0.8.1
|
||||
license-expression==30.4.3
|
||||
mock-open==1.4.0
|
||||
mypy==1.19.1
|
||||
mypy==1.20.0
|
||||
prek==0.2.28
|
||||
pydantic==2.12.2
|
||||
pylint==4.0.5
|
||||
|
||||
@@ -50,7 +50,6 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||
"no_implicit_optional": "true",
|
||||
"warn_incomplete_stub": "true",
|
||||
"warn_redundant_casts": "true",
|
||||
"warn_unused_configs": "true",
|
||||
"warn_unused_ignores": "true",
|
||||
"enable_error_code": ", ".join( # noqa: FLY002
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user