Update mypy-dev to 1.16.0a2 (#137542)

This commit is contained in:
Marc Mueller 2025-02-06 13:43:53 +01:00 committed by GitHub
parent f56d058443
commit a4fe0cbe7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 21 additions and 16 deletions

View File

@ -1531,7 +1531,7 @@ async def async_api_adjust_range(
data: dict[str, Any] = {ATTR_ENTITY_ID: entity.entity_id}
range_delta = directive.payload["rangeValueDelta"]
range_delta_default = bool(directive.payload["rangeValueDeltaDefault"])
response_value: int | None = 0
response_value: float | None = 0
# Cover Position
if instance == f"{cover.DOMAIN}.{cover.ATTR_POSITION}":

View File

@ -387,4 +387,4 @@ def _validate_state_det_rules(state_det_rules: Any) -> list[Any] | None:
except ValueError as exc:
_LOGGER.warning("Invalid state detection rules: %s", exc)
return None
return json_rules # type: ignore[no-any-return]
return json_rules

View File

@ -174,7 +174,7 @@ class WebDavCalendarEntity(CoordinatorEntity[CalDavUpdateCoordinator], CalendarE
def __init__(
self,
name: str,
name: str | None,
entity_id: str,
coordinator: CalDavUpdateCoordinator,
unique_id: str | None = None,

View File

@ -8,7 +8,7 @@ import dataclasses
from functools import partial
import logging
import os
from typing import Any, Final, Self, cast, final
from typing import TYPE_CHECKING, Any, Final, Self, cast, final
from propcache.api import cached_property
import voluptuous as vol
@ -528,6 +528,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
elif ATTR_RGB_COLOR in params and ColorMode.RGB not in supported_color_modes:
rgb_color = params.pop(ATTR_RGB_COLOR)
assert rgb_color is not None
if TYPE_CHECKING:
rgb_color = cast(tuple[int, int, int], rgb_color)
if ColorMode.RGBW in supported_color_modes:
params[ATTR_RGBW_COLOR] = color_util.color_rgb_to_rgbw(*rgb_color)
elif ColorMode.RGBWW in supported_color_modes:
@ -601,6 +603,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
):
rgbww_color = params.pop(ATTR_RGBWW_COLOR)
assert rgbww_color is not None
if TYPE_CHECKING:
rgbww_color = cast(tuple[int, int, int, int, int], rgbww_color)
rgb_color = color_util.color_rgbww_to_rgb(
*rgbww_color, light.min_color_temp_kelvin, light.max_color_temp_kelvin
)

View File

@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from datetime import timedelta
import logging
from typing import Any
from typing import Any, cast
from linear_garage_door import Linear
from linear_garage_door.errors import InvalidLoginError
@ -56,7 +56,7 @@ class LinearUpdateCoordinator(DataUpdateCoordinator[dict[str, LinearDevice]]):
for device in self._devices:
device_id = str(device["id"])
state = await linear.get_device_state(device_id)
data[device_id] = LinearDevice(device["name"], state)
data[device_id] = LinearDevice(cast(str, device["name"]), state)
return data
return await self.execute(update_data)

View File

@ -3,6 +3,7 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, cast
from chip.clusters import Objects as clusters
from chip.clusters.Objects import uint
@ -55,6 +56,8 @@ class MatterBinarySensor(MatterEntity, BinarySensorEntity):
value = None
elif value_convert := self.entity_description.measurement_to_ha:
value = value_convert(value)
if TYPE_CHECKING:
value = cast(bool | None, value)
self._attr_is_on = value

View File

@ -494,7 +494,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
},
NumberDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
NumberDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
NumberDeviceClass.SPEED: {*UnitOfSpeed, *UnitOfVolumetricFlux},
NumberDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
NumberDeviceClass.TEMPERATURE: set(UnitOfTemperature),
NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {

View File

@ -766,7 +766,7 @@ def _sorted_states_to_dict(
attr_cache,
start_time_ts,
entity_id,
prev_state, # type: ignore[arg-type]
prev_state,
first_state[last_updated_ts_idx],
no_attributes,
)

View File

@ -590,7 +590,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = {
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
},
SensorDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
SensorDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
SensorDeviceClass.SPEED: {*UnitOfSpeed, *UnitOfVolumetricFlux},
SensorDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
SensorDeviceClass.TEMPERATURE: set(UnitOfTemperature),
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {

View File

@ -220,7 +220,7 @@ async def handle_info(
# Update subscription of all finished tasks
for result in done:
domain, key = pending_lookup[result]
event_msg = {
event_msg: dict[str, Any] = {
"type": "update",
"domain": domain,
"key": key,

View File

@ -328,7 +328,7 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
host, port = self._async_get_host_port(host)
match_dict = {CONF_HOST: host}
match_dict: dict[str, Any] = {CONF_HOST: host}
if port:
self.port = port
match_dict[CONF_PORT] = port

View File

@ -420,7 +420,7 @@ class ZhaMultiPANMigrationHelper:
self._radio_mgr.radio_type = new_radio_type
self._radio_mgr.device_path = new_device_settings[CONF_DEVICE_PATH]
self._radio_mgr.device_settings = new_device_settings
device_settings = self._radio_mgr.device_settings.copy() # type: ignore[union-attr]
device_settings = self._radio_mgr.device_settings.copy()
# Update the config entry settings
self._hass.config_entries.async_update_entry(

View File

@ -86,9 +86,7 @@ CLEANUP_INTERVAL = 3600 * 24
ORPHANED_ENTITY_KEEP_SECONDS = 3600 * 24 * 30
ENTITY_CATEGORY_VALUE_TO_INDEX: dict[EntityCategory | None, int] = {
# mypy does not understand strenum
val: idx # type: ignore[misc]
for idx, val in enumerate(EntityCategory)
val: idx for idx, val in enumerate(EntityCategory)
}
ENTITY_CATEGORY_INDEX_TO_VALUE = dict(enumerate(EntityCategory))

View File

@ -12,7 +12,7 @@ coverage==7.6.10
freezegun==1.5.1
license-expression==30.4.1
mock-open==1.4.0
mypy-dev==1.16.0a1
mypy-dev==1.16.0a2
pre-commit==4.0.0
pydantic==2.10.6
pylint==3.3.4