mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Remove unnecessary type ignores (#116036)
This commit is contained in:
parent
5e250d8a76
commit
14e19c6d9c
@ -1,5 +1,6 @@
|
|||||||
"""Support for Alexa skill service end point."""
|
"""Support for Alexa skill service end point."""
|
||||||
|
|
||||||
|
from collections.abc import Callable, Coroutine
|
||||||
import enum
|
import enum
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -16,7 +17,9 @@ from .const import DOMAIN, SYN_RESOLUTION_MATCH
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
HANDLERS = Registry() # type: ignore[var-annotated]
|
HANDLERS: Registry[
|
||||||
|
str, Callable[[HomeAssistant, dict[str, Any]], Coroutine[Any, Any, dict[str, Any]]]
|
||||||
|
] = Registry()
|
||||||
|
|
||||||
INTENTS_API_ENDPOINT = "/api/alexa"
|
INTENTS_API_ENDPOINT = "/api/alexa"
|
||||||
|
|
||||||
@ -129,8 +132,7 @@ async def async_handle_message(
|
|||||||
if not (handler := HANDLERS.get(req_type)):
|
if not (handler := HANDLERS.get(req_type)):
|
||||||
raise UnknownRequest(f"Received unknown request {req_type}")
|
raise UnknownRequest(f"Received unknown request {req_type}")
|
||||||
|
|
||||||
response: dict[str, Any] = await handler(hass, message)
|
return await handler(hass, message)
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@HANDLERS.register("SessionEndedRequest")
|
@HANDLERS.register("SessionEndedRequest")
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
"""Describe logbook events."""
|
"""Describe logbook events."""
|
||||||
|
|
||||||
|
from collections.abc import Callable
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.logbook import (
|
from homeassistant.components.logbook import (
|
||||||
LOGBOOK_ENTRY_CONTEXT_ID,
|
LOGBOOK_ENTRY_CONTEXT_ID,
|
||||||
LOGBOOK_ENTRY_ENTITY_ID,
|
LOGBOOK_ENTRY_ENTITY_ID,
|
||||||
@ -16,11 +19,16 @@ from .const import DOMAIN
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_describe_events(hass: HomeAssistant, async_describe_event): # type: ignore[no-untyped-def]
|
def async_describe_events(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
async_describe_event: Callable[
|
||||||
|
[str, str, Callable[[LazyEventPartialState], dict[str, Any]]], None
|
||||||
|
],
|
||||||
|
) -> None:
|
||||||
"""Describe logbook events."""
|
"""Describe logbook events."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_describe_logbook_event(event: LazyEventPartialState): # type: ignore[no-untyped-def]
|
def async_describe_logbook_event(event: LazyEventPartialState) -> dict[str, Any]:
|
||||||
"""Describe a logbook event."""
|
"""Describe a logbook event."""
|
||||||
data = event.data
|
data = event.data
|
||||||
message = "triggered"
|
message = "triggered"
|
||||||
|
@ -33,7 +33,7 @@ from evohomeasync2.schema.const import (
|
|||||||
SZ_TIMING_MODE,
|
SZ_TIMING_MODE,
|
||||||
SZ_UNTIL,
|
SZ_UNTIL,
|
||||||
)
|
)
|
||||||
import voluptuous as vol # type: ignore[import-untyped]
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
@ -462,7 +462,7 @@ class EvoBroker:
|
|||||||
self.client.access_token_expires # type: ignore[arg-type]
|
self.client.access_token_expires # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
|
|
||||||
app_storage = {
|
app_storage: dict[str, Any] = {
|
||||||
CONF_USERNAME: self.client.username,
|
CONF_USERNAME: self.client.username,
|
||||||
REFRESH_TOKEN: self.client.refresh_token,
|
REFRESH_TOKEN: self.client.refresh_token,
|
||||||
ACCESS_TOKEN: self.client.access_token,
|
ACCESS_TOKEN: self.client.access_token,
|
||||||
@ -470,11 +470,11 @@ class EvoBroker:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.client_v1:
|
if self.client_v1:
|
||||||
app_storage[USER_DATA] = { # type: ignore[assignment]
|
app_storage[USER_DATA] = {
|
||||||
SZ_SESSION_ID: self.client_v1.broker.session_id,
|
SZ_SESSION_ID: self.client_v1.broker.session_id,
|
||||||
} # this is the schema for STORAGE_VER == 1
|
} # this is the schema for STORAGE_VER == 1
|
||||||
else:
|
else:
|
||||||
app_storage[USER_DATA] = {} # type: ignore[assignment]
|
app_storage[USER_DATA] = {}
|
||||||
|
|
||||||
await self._store.async_save(app_storage)
|
await self._store.async_save(app_storage)
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class FeedManager:
|
|||||||
def _update(self) -> struct_time | None:
|
def _update(self) -> struct_time | None:
|
||||||
"""Update the feed and publish new entries to the event bus."""
|
"""Update the feed and publish new entries to the event bus."""
|
||||||
_LOGGER.debug("Fetching new data from feed %s", self._url)
|
_LOGGER.debug("Fetching new data from feed %s", self._url)
|
||||||
self._feed: feedparser.FeedParserDict = feedparser.parse( # type: ignore[no-redef]
|
self._feed = feedparser.parse(
|
||||||
self._url,
|
self._url,
|
||||||
etag=None if not self._feed else self._feed.get("etag"),
|
etag=None if not self._feed else self._feed.get("etag"),
|
||||||
modified=None if not self._feed else self._feed.get("modified"),
|
modified=None if not self._feed else self._feed.get("modified"),
|
||||||
|
@ -75,9 +75,9 @@ class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterEntity):
|
|||||||
return list(HA_OPMODE_TO_GH)
|
return list(HA_OPMODE_TO_GH)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_operation(self) -> str:
|
def current_operation(self) -> str | None:
|
||||||
"""Return the current operation mode."""
|
"""Return the current operation mode."""
|
||||||
return GH_STATE_TO_HA[self._zone.data["mode"]] # type: ignore[return-value]
|
return GH_STATE_TO_HA[self._zone.data["mode"]]
|
||||||
|
|
||||||
async def async_set_operation_mode(self, operation_mode: str) -> None:
|
async def async_set_operation_mode(self, operation_mode: str) -> None:
|
||||||
"""Set a new operation mode for this boiler."""
|
"""Set a new operation mode for this boiler."""
|
||||||
|
@ -34,12 +34,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
|
|
||||||
|
|
||||||
def add_defaults(
|
def add_defaults(
|
||||||
input_data: dict[str, Any], default_data: dict[str, Any]
|
input_data: dict[str, Any], default_data: Mapping[str, Any]
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Deep update a dictionary with default values."""
|
"""Deep update a dictionary with default values."""
|
||||||
for key, val in default_data.items():
|
for key, val in default_data.items():
|
||||||
if isinstance(val, Mapping):
|
if isinstance(val, Mapping):
|
||||||
input_data[key] = add_defaults(input_data.get(key, {}), val) # type: ignore[arg-type]
|
input_data[key] = add_defaults(input_data.get(key, {}), val)
|
||||||
elif key not in input_data:
|
elif key not in input_data:
|
||||||
input_data[key] = val
|
input_data[key] = val
|
||||||
return input_data
|
return input_data
|
||||||
|
@ -264,7 +264,7 @@ class InputText(collection.CollectionEntity, RestoreEntity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
state = await self.async_get_last_state()
|
state = await self.async_get_last_state()
|
||||||
value: str | None = state and state.state # type: ignore[assignment]
|
value = state.state if state else None
|
||||||
|
|
||||||
# Check against None because value can be 0
|
# Check against None because value can be 0
|
||||||
if value is not None and self._minimum <= len(value) <= self._maximum:
|
if value is not None and self._minimum <= len(value) <= self._maximum:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user