mirror of
https://github.com/home-assistant/core.git
synced 2026-08-03 20:24:55 +02:00
Update mypy to 2.2.0 (#175924)
This commit is contained in:
@@ -204,7 +204,7 @@ class AppleTvMediaPlayer(
|
||||
return MediaPlayerState.PLAYING
|
||||
if state in (DeviceState.Paused, DeviceState.Seeking, DeviceState.Stopped):
|
||||
return MediaPlayerState.PAUSED
|
||||
return MediaPlayerState.IDLE # Bad or unknown state?
|
||||
return MediaPlayerState.IDLE # type: ignore[unreachable] # Bad or unknown state?
|
||||
return None
|
||||
|
||||
@callback
|
||||
|
||||
@@ -151,8 +151,7 @@ async def async_attach_trigger(
|
||||
if isinstance(
|
||||
automation_result, ScriptRunResult
|
||||
) and automation_result.conversation_response not in (None, UNDEFINED):
|
||||
# mypy does not understand the type narrowing, unclear why
|
||||
return automation_result.conversation_response # type: ignore[return-value]
|
||||
return automation_result.conversation_response
|
||||
|
||||
# It's important to return None here instead of a string.
|
||||
#
|
||||
|
||||
@@ -104,7 +104,7 @@ TRANSLATION_KEYS_PROGRAMS_MAP = {
|
||||
if program not in (ProgramKey.UNKNOWN, *FAVORITE_PROGRAMS)
|
||||
}
|
||||
|
||||
PROGRAMS_TRANSLATION_KEYS_MAP = {
|
||||
PROGRAMS_TRANSLATION_KEYS_MAP: dict[ProgramKey, str] = {
|
||||
value: key for key, value in TRANSLATION_KEYS_PROGRAMS_MAP.items()
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ class HomeAssistantHTTP:
|
||||
async def redirect(request: web.Request) -> web.StreamResponse:
|
||||
"""Redirect to location."""
|
||||
# Should be instance of aiohttp.web_exceptions._HTTPMove.
|
||||
raise redirect_exc(redirect_to) # type: ignore[arg-type,misc]
|
||||
raise redirect_exc(redirect_to) # type: ignore[arg-type,call-arg]
|
||||
|
||||
self.app[KEY_ALLOW_CONFIGURED_CORS](
|
||||
self.app.router.add_route("GET", url, redirect)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"""Provides device triggers for LCN."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_automation import DEVICE_TRIGGER_BASE_SCHEMA
|
||||
@@ -75,7 +77,7 @@ async def async_attach_trigger(
|
||||
trigger_info: TriggerInfo,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Attach a trigger."""
|
||||
event_data = {
|
||||
event_data: dict[str, Any] = {
|
||||
CONF_DEVICE_ID: config[CONF_DEVICE_ID],
|
||||
**{
|
||||
key: config[key]
|
||||
|
||||
@@ -118,6 +118,11 @@ class Streams:
|
||||
@asynccontextmanager
|
||||
async def create_streams() -> AsyncGenerator[Streams]:
|
||||
"""Create a new pair of streams for MCP server communication."""
|
||||
read_stream: MemoryObjectReceiveStream[SessionMessage | Exception]
|
||||
read_stream_writer: MemoryObjectSendStream[SessionMessage | Exception]
|
||||
write_stream: MemoryObjectSendStream[SessionMessage]
|
||||
write_stream_reader: MemoryObjectReceiveStream[SessionMessage]
|
||||
|
||||
read_stream_writer, read_stream = anyio.create_memory_object_stream(0)
|
||||
write_stream, write_stream_reader = anyio.create_memory_object_stream(0)
|
||||
streams = Streams(
|
||||
|
||||
@@ -56,7 +56,7 @@ def _async_short_mac(mac: str) -> str:
|
||||
return _async_unifi_mac_from_hass(mac)[-6:]
|
||||
|
||||
|
||||
async def _async_resolve(hass: HomeAssistant, host: str) -> str | None:
|
||||
async def _async_resolve(hass: HomeAssistant, host: str) -> str | int | None:
|
||||
"""Resolve a hostname to an ip."""
|
||||
with contextlib.suppress(OSError):
|
||||
return next(
|
||||
|
||||
@@ -557,7 +557,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||
# and cool to mirror previous behavior. If none of those are available, set it
|
||||
# to the first available mode that is not off.
|
||||
try:
|
||||
hvac_mode = next(
|
||||
hvac_mode: HVACMode = next(
|
||||
mode
|
||||
for mode in (HVACMode.HEAT_COOL, HVACMode.HEAT, HVACMode.COOL)
|
||||
if mode in self._hvac_modes
|
||||
|
||||
@@ -18,7 +18,7 @@ import threading
|
||||
import time
|
||||
from time import monotonic
|
||||
import traceback
|
||||
from typing import Any
|
||||
from typing import Any, override
|
||||
|
||||
import packaging.tags
|
||||
|
||||
@@ -173,7 +173,7 @@ class RuntimeConfig:
|
||||
safe_mode: bool = False
|
||||
|
||||
|
||||
class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[name-defined,misc]
|
||||
class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy):
|
||||
"""Event loop policy for Home Assistant."""
|
||||
|
||||
def __init__(self, debug: bool) -> None:
|
||||
@@ -184,8 +184,9 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[name-
|
||||
@property
|
||||
def loop_name(self) -> str:
|
||||
"""Return name of the loop."""
|
||||
return self._loop_factory.__name__ # type: ignore[no-any-return]
|
||||
return self._loop_factory.__name__ # type: ignore[attr-defined,no-any-return]
|
||||
|
||||
@override
|
||||
def new_event_loop(self) -> asyncio.AbstractEventLoop:
|
||||
"""Get the event loop."""
|
||||
loop: asyncio.AbstractEventLoop = super().new_event_loop()
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
-c homeassistant/package_constraints.txt
|
||||
-r requirements_test_pre_commit.txt
|
||||
# ast-serialize is an internal mypy dependency
|
||||
ast-serialize==0.3.0
|
||||
ast-serialize==0.6.0
|
||||
astroid==4.0.4
|
||||
coverage==7.14.3
|
||||
freezegun==1.5.5
|
||||
# librt is an internal mypy dependency
|
||||
librt==0.11.0
|
||||
librt==0.12.0
|
||||
license-expression==30.4.3
|
||||
mock-open==1.4.0
|
||||
mypy==2.1.0
|
||||
mypy==2.2.0
|
||||
prek==0.2.28
|
||||
pydantic==2.13.4
|
||||
PyGithub==2.9.1
|
||||
|
||||
Reference in New Issue
Block a user