Update mypy to 1.4.0 (#94987)

This commit is contained in:
Marc Mueller 2023-06-21 16:12:51 +02:00 committed by GitHub
parent c8cd469c95
commit 86792fcc2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 31 additions and 35 deletions

View File

@ -71,7 +71,7 @@ async def async_attach_trigger(
job,
{
"trigger": {
**trigger_data, # type: ignore[arg-type] # https://github.com/python/mypy/issues/9117
**trigger_data,
**config,
"description": f"{DOMAIN} - {entity_id}",
}

View File

@ -78,7 +78,7 @@ class DemoMailbox(Mailbox):
"""Return a list of the current messages."""
return sorted(
self._messages.values(),
key=lambda item: item["info"]["origtime"], # type: ignore[no-any-return]
key=lambda item: item["info"]["origtime"],
reverse=True,
)

View File

@ -28,10 +28,10 @@ class DomainData:
_entry_datas: dict[str, RuntimeEntryData] = field(default_factory=dict)
_stores: dict[str, Store] = field(default_factory=dict)
_gatt_services_cache: MutableMapping[int, BleakGATTServiceCollection] = field(
default_factory=lambda: LRU(MAX_CACHED_SERVICES) # type: ignore[no-any-return]
default_factory=lambda: LRU(MAX_CACHED_SERVICES)
)
_gatt_mtu_cache: MutableMapping[int, int] = field(
default_factory=lambda: LRU(MAX_CACHED_SERVICES) # type: ignore[no-any-return]
default_factory=lambda: LRU(MAX_CACHED_SERVICES)
)
def get_gatt_services_cache(

View File

@ -42,8 +42,8 @@ BINARY_SENSOR_TYPES: Final[tuple[FritzBinarySensorEntityDescription, ...]] = (
key="alarm",
translation_key="alarm",
device_class=BinarySensorDeviceClass.WINDOW,
suitable=lambda device: device.has_alarm, # type: ignore[no-any-return]
is_on=lambda device: device.alert_state, # type: ignore[no-any-return]
suitable=lambda device: device.has_alarm,
is_on=lambda device: device.alert_state,
),
FritzBinarySensorEntityDescription(
key="lock",

View File

@ -97,7 +97,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
suitable=suitable_temperature,
native_value=lambda device: device.temperature, # type: ignore[no-any-return]
native_value=lambda device: device.temperature,
),
FritzSensorEntityDescription(
key="humidity",
@ -106,7 +106,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.rel_humidity is not None,
native_value=lambda device: device.rel_humidity, # type: ignore[no-any-return]
native_value=lambda device: device.rel_humidity,
),
FritzSensorEntityDescription(
key="battery",
@ -115,7 +115,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
suitable=lambda device: device.battery_level is not None,
native_value=lambda device: device.battery_level, # type: ignore[no-any-return]
native_value=lambda device: device.battery_level,
),
FritzSensorEntityDescription(
key="power_consumption",
@ -123,7 +123,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
suitable=lambda device: device.has_powermeter,
native_value=lambda device: round((device.power or 0.0) / 1000, 3),
),
FritzSensorEntityDescription(
@ -132,7 +132,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
suitable=lambda device: device.has_powermeter,
native_value=lambda device: round((device.voltage or 0.0) / 1000, 2),
),
FritzSensorEntityDescription(
@ -141,7 +141,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
suitable=lambda device: device.has_powermeter,
native_value=lambda device: round((device.current or 0.0) / 1000, 3),
),
FritzSensorEntityDescription(
@ -150,7 +150,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
suitable=lambda device: device.has_powermeter,
native_value=lambda device: (device.energy or 0.0) / 1000,
),
# Thermostat Sensors
@ -161,7 +161,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
suitable=suitable_comfort_temperature,
native_value=lambda device: device.comfort_temperature, # type: ignore[no-any-return]
native_value=lambda device: device.comfort_temperature,
),
FritzSensorEntityDescription(
key="eco_temperature",
@ -170,7 +170,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
suitable=suitable_eco_temperature,
native_value=lambda device: device.eco_temperature, # type: ignore[no-any-return]
native_value=lambda device: device.eco_temperature,
),
FritzSensorEntityDescription(
key="nextchange_temperature",
@ -179,7 +179,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
suitable=suitable_nextchange_temperature,
native_value=lambda device: device.nextchange_temperature, # type: ignore[no-any-return]
native_value=lambda device: device.nextchange_temperature,
),
FritzSensorEntityDescription(
key="nextchange_time",

View File

@ -189,7 +189,7 @@ class JellyfinSource(MediaSource):
async def _build_artists(self, library_id: str) -> list[BrowseMediaSource]:
"""Return all artists in the music library."""
artists = await self._get_children(library_id, ITEM_TYPE_ARTIST)
artists = sorted(artists, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
artists = sorted(artists, key=lambda k: k[ITEM_KEY_NAME])
return [await self._build_artist(artist, False) for artist in artists]
async def _build_artist(
@ -220,7 +220,7 @@ class JellyfinSource(MediaSource):
async def _build_albums(self, parent_id: str) -> list[BrowseMediaSource]:
"""Return all albums of a single artist as browsable media sources."""
albums = await self._get_children(parent_id, ITEM_TYPE_ALBUM)
albums = sorted(albums, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
albums = sorted(albums, key=lambda k: k[ITEM_KEY_NAME])
return [await self._build_album(album, False) for album in albums]
async def _build_album(
@ -310,7 +310,7 @@ class JellyfinSource(MediaSource):
async def _build_movies(self, library_id: str) -> list[BrowseMediaSource]:
"""Return all movies in the movie library."""
movies = await self._get_children(library_id, ITEM_TYPE_MOVIE)
movies = sorted(movies, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
movies = sorted(movies, key=lambda k: k[ITEM_KEY_NAME])
return [
self._build_movie(movie)
for movie in movies
@ -363,7 +363,7 @@ class JellyfinSource(MediaSource):
async def _build_tvshow(self, library_id: str) -> list[BrowseMediaSource]:
"""Return all series in the tv library."""
series = await self._get_children(library_id, ITEM_TYPE_SERIES)
series = sorted(series, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
series = sorted(series, key=lambda k: k[ITEM_KEY_NAME])
return [await self._build_series(serie, False) for serie in series]
async def _build_series(
@ -394,7 +394,7 @@ class JellyfinSource(MediaSource):
async def _build_seasons(self, series_id: str) -> list[BrowseMediaSource]:
"""Return all seasons in the series."""
seasons = await self._get_children(series_id, ITEM_TYPE_SEASON)
seasons = sorted(seasons, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
seasons = sorted(seasons, key=lambda k: k[ITEM_KEY_NAME])
return [await self._build_season(season, False) for season in seasons]
async def _build_season(
@ -425,7 +425,7 @@ class JellyfinSource(MediaSource):
async def _build_episodes(self, season_id: str) -> list[BrowseMediaSource]:
"""Return all episode in the season."""
episodes = await self._get_children(season_id, ITEM_TYPE_EPISODE)
episodes = sorted(episodes, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return]
episodes = sorted(episodes, key=lambda k: k[ITEM_KEY_NAME])
return [
self._build_episode(episode)
for episode in episodes

View File

@ -71,7 +71,7 @@ SYSTEM_ENTITY_DESCRIPTIONS = (
device_class=SensorDeviceClass.ENUM,
options=[opt.value for opt in XknxConnectionType],
should_poll=False,
value_fn=lambda knx: knx.xknx.connection_manager.connection_type.value, # type: ignore[no-any-return]
value_fn=lambda knx: knx.xknx.connection_manager.connection_type.value,
),
KNXSystemEntityDescription(
key="telegrams_incoming",

View File

@ -93,7 +93,7 @@ def setup_platform(
_LOGGER.warning("Unable to open serial port: %s", exc)
return
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda event: lacrosse.close()) # type: ignore[no-any-return]
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda event: lacrosse.close())
if CONF_JEELINK_LED in config:
lacrosse.led_mode_state(config.get(CONF_JEELINK_LED))

View File

@ -63,7 +63,7 @@ async def async_attach_trigger(
job,
{
"trigger": {
**trigger_data, # type: ignore[arg-type] # https://github.com/python/mypy/issues/9117
**trigger_data,
"platform": "persistent_notification",
"update_type": update_type,
"notification": notification,

View File

@ -6,7 +6,7 @@ from collections.abc import Coroutine
import contextlib
from datetime import timedelta
import logging
from typing import Any, cast
from typing import Any
import httpx
import voluptuous as vol
@ -160,11 +160,7 @@ def _rest_coordinator(
if resource_template:
async def _async_refresh_with_resource_template() -> None:
rest.set_url(
cast(template.Template, resource_template).async_render(
parse_result=False
)
)
rest.set_url(resource_template.async_render(parse_result=False))
await rest.async_update()
update_method = _async_refresh_with_resource_template

View File

@ -206,7 +206,7 @@ def process_before_send(
"channel": channel,
"custom_components": "\n".join(sorted(custom_components)),
"integrations": "\n".join(sorted(integrations)),
**system_info, # type: ignore[arg-type]
**system_info,
},
}
)

View File

@ -155,7 +155,7 @@ def _async_device_as_dict(hass: HomeAssistant, device: TuyaDevice) -> dict[str,
for entity_entry in hass_entities:
state = hass.states.get(entity_entry.entity_id)
state_dict = None
state_dict: dict[str, Any] | None = None
if state:
state_dict = dict(state.as_dict())

View File

@ -38,7 +38,7 @@ def singleton(data_key: str) -> Callable[[_FuncType[_T]], _FuncType[_T]]:
async def async_wrapped(hass: HomeAssistant) -> Any:
if data_key not in hass.data:
evt = hass.data[data_key] = asyncio.Event()
result = await func(hass) # type: ignore[misc]
result = await func(hass)
hass.data[data_key] = result
evt.set()
return cast(_T, result)

View File

@ -11,7 +11,7 @@ astroid==2.15.4
coverage==7.2.4
freezegun==1.2.2
mock-open==1.4.0
mypy==1.3.0
mypy==1.4.0
pre-commit==3.1.0
pydantic==1.10.9
pylint==2.17.4