mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Remove unnecessary type casts (#137657)
This commit is contained in:
parent
d9726ab08c
commit
4c9127a0ea
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import cast
|
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -43,9 +42,7 @@ async def async_setup_platform(
|
|||||||
if not discovery_info:
|
if not discovery_info:
|
||||||
return
|
return
|
||||||
|
|
||||||
discovery_info = cast(DiscoveryInfoType, discovery_info)
|
|
||||||
binary_sensor_config = discovery_info
|
binary_sensor_config = discovery_info
|
||||||
|
|
||||||
command: str = binary_sensor_config[CONF_COMMAND]
|
command: str = binary_sensor_config[CONF_COMMAND]
|
||||||
payload_off: str = binary_sensor_config[CONF_PAYLOAD_OFF]
|
payload_off: str = binary_sensor_config[CONF_PAYLOAD_OFF]
|
||||||
payload_on: str = binary_sensor_config[CONF_PAYLOAD_ON]
|
payload_on: str = binary_sensor_config[CONF_PAYLOAD_ON]
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from homeassistant.components.cover import CoverEntity
|
from homeassistant.components.cover import CoverEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -41,7 +41,6 @@ async def async_setup_platform(
|
|||||||
return
|
return
|
||||||
|
|
||||||
covers = []
|
covers = []
|
||||||
discovery_info = cast(DiscoveryInfoType, discovery_info)
|
|
||||||
entities: dict[str, dict[str, Any]] = {
|
entities: dict[str, dict[str, Any]] = {
|
||||||
slugify(discovery_info[CONF_NAME]): discovery_info
|
slugify(discovery_info[CONF_NAME]): discovery_info
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Any, cast
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.notify import BaseNotificationService
|
from homeassistant.components.notify import BaseNotificationService
|
||||||
from homeassistant.const import CONF_COMMAND
|
from homeassistant.const import CONF_COMMAND
|
||||||
@ -26,7 +26,6 @@ def get_service(
|
|||||||
if not discovery_info:
|
if not discovery_info:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
discovery_info = cast(DiscoveryInfoType, discovery_info)
|
|
||||||
notify_config = discovery_info
|
notify_config = discovery_info
|
||||||
command: str = notify_config[CONF_COMMAND]
|
command: str = notify_config[CONF_COMMAND]
|
||||||
timeout: int = notify_config[CONF_COMMAND_TIMEOUT]
|
timeout: int = notify_config[CONF_COMMAND_TIMEOUT]
|
||||||
|
@ -6,7 +6,7 @@ import asyncio
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import json
|
import json
|
||||||
from typing import Any, cast
|
from typing import Any
|
||||||
|
|
||||||
from jsonpath import jsonpath
|
from jsonpath import jsonpath
|
||||||
|
|
||||||
@ -51,9 +51,7 @@ async def async_setup_platform(
|
|||||||
if not discovery_info:
|
if not discovery_info:
|
||||||
return
|
return
|
||||||
|
|
||||||
discovery_info = cast(DiscoveryInfoType, discovery_info)
|
|
||||||
sensor_config = discovery_info
|
sensor_config = discovery_info
|
||||||
|
|
||||||
command: str = sensor_config[CONF_COMMAND]
|
command: str = sensor_config[CONF_COMMAND]
|
||||||
command_timeout: int = sensor_config[CONF_COMMAND_TIMEOUT]
|
command_timeout: int = sensor_config[CONF_COMMAND_TIMEOUT]
|
||||||
json_attributes: list[str] | None = sensor_config.get(CONF_JSON_ATTRIBUTES)
|
json_attributes: list[str] | None = sensor_config.get(CONF_JSON_ATTRIBUTES)
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import TYPE_CHECKING, Any, cast
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -40,7 +40,6 @@ async def async_setup_platform(
|
|||||||
return
|
return
|
||||||
|
|
||||||
switches = []
|
switches = []
|
||||||
discovery_info = cast(DiscoveryInfoType, discovery_info)
|
|
||||||
entities: dict[str, dict[str, Any]] = {
|
entities: dict[str, dict[str, Any]] = {
|
||||||
slugify(discovery_info[CONF_NAME]): discovery_info
|
slugify(discovery_info[CONF_NAME]): discovery_info
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ def setup_services(hass: HomeAssistant) -> None:
|
|||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="end_date_before_start_date",
|
translation_key="end_date_before_start_date",
|
||||||
)
|
)
|
||||||
client = cast(MealieConfigEntry, entry).runtime_data.client
|
client = entry.runtime_data.client
|
||||||
try:
|
try:
|
||||||
mealplans = await client.get_mealplans(start_date, end_date)
|
mealplans = await client.get_mealplans(start_date, end_date)
|
||||||
except MealieConnectionError as err:
|
except MealieConnectionError as err:
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import TYPE_CHECKING, Any, Literal, Required, TypedDict, cast
|
from typing import Any, Required, TypedDict, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -177,8 +177,6 @@ class NWSWeather(CoordinatorWeatherEntity[TimestampDataUpdateCoordinator[None]])
|
|||||||
for forecast_type in ("twice_daily", "hourly"):
|
for forecast_type in ("twice_daily", "hourly"):
|
||||||
if (coordinator := self.forecast_coordinators[forecast_type]) is None:
|
if (coordinator := self.forecast_coordinators[forecast_type]) is None:
|
||||||
continue
|
continue
|
||||||
if TYPE_CHECKING:
|
|
||||||
forecast_type = cast(Literal["twice_daily", "hourly"], forecast_type)
|
|
||||||
self.unsub_forecast[forecast_type] = coordinator.async_add_listener(
|
self.unsub_forecast[forecast_type] = coordinator.async_add_listener(
|
||||||
partial(self._handle_forecast_update, forecast_type)
|
partial(self._handle_forecast_update, forecast_type)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user