Update mypy-dev to 1.16.0a7 (#141472)

This commit is contained in:
Marc Mueller 2025-03-26 15:21:38 +01:00 committed by GitHub
parent 0de3549e6e
commit 1622638f10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 46 additions and 25 deletions

View File

@ -1438,7 +1438,7 @@ class AlexaModeController(AlexaCapability):
# Fan preset_mode # Fan preset_mode
if self.instance == f"{fan.DOMAIN}.{fan.ATTR_PRESET_MODE}": if self.instance == f"{fan.DOMAIN}.{fan.ATTR_PRESET_MODE}":
mode = self.entity.attributes.get(fan.ATTR_PRESET_MODE, None) mode = self.entity.attributes.get(fan.ATTR_PRESET_MODE, None)
if mode in self.entity.attributes.get(fan.ATTR_PRESET_MODES, None): if mode in self.entity.attributes.get(fan.ATTR_PRESET_MODES, ()):
return f"{fan.ATTR_PRESET_MODE}.{mode}" return f"{fan.ATTR_PRESET_MODE}.{mode}"
# Humidifier mode # Humidifier mode

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any from typing import Any, cast
import pyeverlights import pyeverlights
import voluptuous as vol import voluptuous as vol
@ -84,7 +84,7 @@ class EverLightsLight(LightEntity):
api: pyeverlights.EverLights, api: pyeverlights.EverLights,
channel: int, channel: int,
status: dict[str, Any], status: dict[str, Any],
effects, effects: list[str],
) -> None: ) -> None:
"""Initialize the light.""" """Initialize the light."""
self._api = api self._api = api
@ -106,8 +106,10 @@ class EverLightsLight(LightEntity):
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the light on.""" """Turn the light on."""
hs_color = kwargs.get(ATTR_HS_COLOR, self._attr_hs_color) hs_color = cast(
brightness = kwargs.get(ATTR_BRIGHTNESS, self._attr_brightness) tuple[float, float], kwargs.get(ATTR_HS_COLOR, self._attr_hs_color)
)
brightness = cast(int, kwargs.get(ATTR_BRIGHTNESS, self._attr_brightness))
effect = kwargs.get(ATTR_EFFECT) effect = kwargs.get(ATTR_EFFECT)
if effect is not None: if effect is not None:
@ -116,7 +118,7 @@ class EverLightsLight(LightEntity):
rgb = color_int_to_rgb(colors[0]) rgb = color_int_to_rgb(colors[0])
hsv = color_util.color_RGB_to_hsv(*rgb) hsv = color_util.color_RGB_to_hsv(*rgb)
hs_color = hsv[:2] hs_color = hsv[:2]
brightness = hsv[2] / 100 * 255 brightness = round(hsv[2] / 100 * 255)
else: else:
rgb = color_util.color_hsv_to_RGB( rgb = color_util.color_hsv_to_RGB(

View File

@ -5,7 +5,7 @@ from __future__ import annotations
from collections import namedtuple from collections import namedtuple
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Any from typing import Any, cast
from fints.client import FinTS3PinTanClient from fints.client import FinTS3PinTanClient
from fints.models import SEPAAccount from fints.models import SEPAAccount
@ -73,7 +73,7 @@ def setup_platform(
credentials = BankCredentials( credentials = BankCredentials(
config[CONF_BIN], config[CONF_USERNAME], config[CONF_PIN], config[CONF_URL] config[CONF_BIN], config[CONF_USERNAME], config[CONF_PIN], config[CONF_URL]
) )
fints_name = config.get(CONF_NAME, config[CONF_BIN]) fints_name = cast(str, config.get(CONF_NAME, config[CONF_BIN]))
account_config = { account_config = {
acc[CONF_ACCOUNT]: acc[CONF_NAME] for acc in config[CONF_ACCOUNTS] acc[CONF_ACCOUNT]: acc[CONF_NAME] for acc in config[CONF_ACCOUNTS]

View File

@ -207,11 +207,13 @@ class HomeConnectLight(HomeConnectEntity, LightEntity):
brightness = round( brightness = round(
color_util.brightness_to_value( color_util.brightness_to_value(
self._brightness_scale, self._brightness_scale,
kwargs.get(ATTR_BRIGHTNESS, self._attr_brightness), cast(int, kwargs.get(ATTR_BRIGHTNESS, self._attr_brightness)),
) )
) )
hs_color = kwargs.get(ATTR_HS_COLOR, self._attr_hs_color) hs_color = cast(
tuple[float, float], kwargs.get(ATTR_HS_COLOR, self._attr_hs_color)
)
rgb = color_util.color_hsv_to_RGB(hs_color[0], hs_color[1], brightness) rgb = color_util.color_hsv_to_RGB(hs_color[0], hs_color[1], brightness)
hex_val = color_util.color_rgb_to_hex(*rgb) hex_val = color_util.color_rgb_to_hex(*rgb)

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Any from typing import Any, cast
from led_ble import LEDBLE from led_ble import LEDBLE
@ -83,7 +83,7 @@ class LEDBLEEntity(CoordinatorEntity[DataUpdateCoordinator[None]], LightEntity):
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the light to turn on.""" """Instruct the light to turn on."""
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness) brightness = cast(int, kwargs.get(ATTR_BRIGHTNESS, self.brightness))
if effect := kwargs.get(ATTR_EFFECT): if effect := kwargs.get(ATTR_EFFECT):
await self._async_set_effect(effect, brightness) await self._async_set_effect(effect, brightness)
return return

View File

@ -465,7 +465,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
): ):
params.pop(_DEPRECATED_ATTR_COLOR_TEMP.value) params.pop(_DEPRECATED_ATTR_COLOR_TEMP.value)
color_temp = params.pop(ATTR_COLOR_TEMP_KELVIN) color_temp = params.pop(ATTR_COLOR_TEMP_KELVIN)
brightness = params.get(ATTR_BRIGHTNESS, light.brightness) brightness = cast(int, params.get(ATTR_BRIGHTNESS, light.brightness))
params[ATTR_RGBWW_COLOR] = color_util.color_temperature_to_rgbww( params[ATTR_RGBWW_COLOR] = color_util.color_temperature_to_rgbww(
color_temp, color_temp,
brightness, brightness,

View File

@ -3,7 +3,7 @@
from __future__ import annotations from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from typing import Any from typing import Any, cast
from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW, AtaDevice, AtwDevice from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW, AtaDevice, AtwDevice
import pymelcloud.ata_device as ata import pymelcloud.ata_device as ata
@ -236,7 +236,7 @@ class AtaDeviceClimate(MelCloudClimate):
set_dict: dict[str, Any] = {} set_dict: dict[str, Any] = {}
if ATTR_HVAC_MODE in kwargs: if ATTR_HVAC_MODE in kwargs:
self._apply_set_hvac_mode( self._apply_set_hvac_mode(
kwargs.get(ATTR_HVAC_MODE, self.hvac_mode), set_dict cast(HVACMode, kwargs.get(ATTR_HVAC_MODE, self.hvac_mode)), set_dict
) )
if ATTR_TEMPERATURE in kwargs: if ATTR_TEMPERATURE in kwargs:

View File

@ -3,7 +3,7 @@
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any from typing import Any, cast
from haphilipsjs import PhilipsTV from haphilipsjs import PhilipsTV
from haphilipsjs.typing import AmbilightCurrentConfiguration from haphilipsjs.typing import AmbilightCurrentConfiguration
@ -328,7 +328,7 @@ class PhilipsTVLightEntity(PhilipsJsEntity, LightEntity):
"""Turn the bulb on.""" """Turn the bulb on."""
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness) brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness)
hs_color = kwargs.get(ATTR_HS_COLOR, self.hs_color) hs_color = kwargs.get(ATTR_HS_COLOR, self.hs_color)
attr_effect = kwargs.get(ATTR_EFFECT, self.effect) attr_effect = cast(str, kwargs.get(ATTR_EFFECT, self.effect))
if not self._tv.on: if not self._tv.on:
raise HomeAssistantError("TV is not available") raise HomeAssistantError("TV is not available")

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Any from typing import Any, cast
from switchbot import ColorMode as SwitchBotColorMode, SwitchbotBaseLight from switchbot import ColorMode as SwitchBotColorMode, SwitchbotBaseLight
@ -68,7 +68,9 @@ class SwitchbotLightEntity(SwitchbotEntity, LightEntity):
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the light to turn on.""" """Instruct the light to turn on."""
brightness = round(kwargs.get(ATTR_BRIGHTNESS, self.brightness) / 255 * 100) brightness = round(
cast(int, kwargs.get(ATTR_BRIGHTNESS, self.brightness)) / 255 * 100
)
if ( if (
self.supported_color_modes self.supported_color_modes

View File

@ -3,7 +3,7 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from typing import Any from typing import Any, cast
from uuid import uuid4 from uuid import uuid4
from pytradfri import Gateway, RequestError from pytradfri import Gateway, RequestError
@ -54,7 +54,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
errors: dict[str, str] = {} errors: dict[str, str] = {}
if user_input is not None: if user_input is not None:
host = user_input.get(CONF_HOST, self._host) host = cast(str, user_input.get(CONF_HOST, self._host))
try: try:
auth = await authenticate( auth = await authenticate(
self.hass, host, user_input[KEY_SECURITY_CODE] self.hass, host, user_input[KEY_SECURITY_CODE]

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from typing import Any, cast from typing import TYPE_CHECKING, Any, cast
from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const import ( from zwave_js_server.const import (
@ -483,7 +483,7 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
red = multi_color.get(COLOR_SWITCH_COMBINED_RED, red_val.value) red = multi_color.get(COLOR_SWITCH_COMBINED_RED, red_val.value)
green = multi_color.get(COLOR_SWITCH_COMBINED_GREEN, green_val.value) green = multi_color.get(COLOR_SWITCH_COMBINED_GREEN, green_val.value)
blue = multi_color.get(COLOR_SWITCH_COMBINED_BLUE, blue_val.value) blue = multi_color.get(COLOR_SWITCH_COMBINED_BLUE, blue_val.value)
if None not in (red, green, blue): if red is not None and green is not None and blue is not None:
# convert to HS # convert to HS
self._hs_color = color_util.color_RGB_to_hs(red, green, blue) self._hs_color = color_util.color_RGB_to_hs(red, green, blue)
# Light supports color, set color mode to hs # Light supports color, set color mode to hs
@ -496,7 +496,8 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
# Calculate color temps based on whites # Calculate color temps based on whites
if cold_white or warm_white: if cold_white or warm_white:
self._color_temp = color_util.color_temperature_mired_to_kelvin( self._color_temp = color_util.color_temperature_mired_to_kelvin(
MAX_MIREDS - ((cold_white / 255) * (MAX_MIREDS - MIN_MIREDS)) MAX_MIREDS
- ((cast(int, cold_white) / 255) * (MAX_MIREDS - MIN_MIREDS))
) )
# White channels turned on, set color mode to color_temp # White channels turned on, set color mode to color_temp
self._color_mode = ColorMode.COLOR_TEMP self._color_mode = ColorMode.COLOR_TEMP
@ -505,6 +506,13 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
# only one white channel (warm white) = rgbw support # only one white channel (warm white) = rgbw support
elif red_val and green_val and blue_val and ww_val: elif red_val and green_val and blue_val and ww_val:
white = multi_color.get(COLOR_SWITCH_COMBINED_WARM_WHITE, ww_val.value) white = multi_color.get(COLOR_SWITCH_COMBINED_WARM_WHITE, ww_val.value)
if TYPE_CHECKING:
assert (
red is not None
and green is not None
and blue is not None
and white is not None
)
self._rgbw_color = (red, green, blue, white) self._rgbw_color = (red, green, blue, white)
# Light supports rgbw, set color mode to rgbw # Light supports rgbw, set color mode to rgbw
self._color_mode = ColorMode.RGBW self._color_mode = ColorMode.RGBW
@ -512,6 +520,13 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
elif cw_val: elif cw_val:
self._supports_rgbw = True self._supports_rgbw = True
white = multi_color.get(COLOR_SWITCH_COMBINED_COLD_WHITE, cw_val.value) white = multi_color.get(COLOR_SWITCH_COMBINED_COLD_WHITE, cw_val.value)
if TYPE_CHECKING:
assert (
red is not None
and green is not None
and blue is not None
and white is not None
)
self._rgbw_color = (red, green, blue, white) self._rgbw_color = (red, green, blue, white)
# Light supports rgbw, set color mode to rgbw # Light supports rgbw, set color mode to rgbw
self._color_mode = ColorMode.RGBW self._color_mode = ColorMode.RGBW

View File

@ -12,7 +12,7 @@ coverage==7.6.12
freezegun==1.5.1 freezegun==1.5.1
license-expression==30.4.1 license-expression==30.4.1
mock-open==1.4.0 mock-open==1.4.0
mypy-dev==1.16.0a5 mypy-dev==1.16.0a7
pre-commit==4.0.0 pre-commit==4.0.0
pydantic==2.10.6 pydantic==2.10.6
pylint==3.3.6 pylint==3.3.6