diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index 2a9525181f6..2d0c98cdd14 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -34,9 +34,9 @@ EVENT_USER_ADDED = "user_added" EVENT_USER_UPDATED = "user_updated" EVENT_USER_REMOVED = "user_removed" -_MfaModuleDict = dict[str, MultiFactorAuthModule] -_ProviderKey = tuple[str, str | None] -_ProviderDict = dict[_ProviderKey, AuthProvider] +type _MfaModuleDict = dict[str, MultiFactorAuthModule] +type _ProviderKey = tuple[str, str | None] +type _ProviderDict = dict[_ProviderKey, AuthProvider] class InvalidAuthError(Exception): diff --git a/homeassistant/auth/mfa_modules/notify.py b/homeassistant/auth/mfa_modules/notify.py index 72edb195a81..d2010dc2c9d 100644 --- a/homeassistant/auth/mfa_modules/notify.py +++ b/homeassistant/auth/mfa_modules/notify.py @@ -88,7 +88,7 @@ class NotifySetting: target: str | None = attr.ib(default=None) -_UsersDict = dict[str, NotifySetting] +type _UsersDict = dict[str, NotifySetting] @MULTI_FACTOR_AUTH_MODULES.register("notify") diff --git a/homeassistant/auth/permissions/types.py b/homeassistant/auth/permissions/types.py index 3411ae860fb..a4bef86241b 100644 --- a/homeassistant/auth/permissions/types.py +++ b/homeassistant/auth/permissions/types.py @@ -4,17 +4,17 @@ from collections.abc import Mapping # MyPy doesn't support recursion yet. So writing it out as far as we need. -ValueType = ( +type ValueType = ( # Example: entities.all = { read: true, control: true } Mapping[str, bool] | bool | None ) # Example: entities.domains = { light: … } -SubCategoryDict = Mapping[str, ValueType] +type SubCategoryDict = Mapping[str, ValueType] -SubCategoryType = SubCategoryDict | bool | None +type SubCategoryType = SubCategoryDict | bool | None -CategoryType = ( +type CategoryType = ( # Example: entities.domains Mapping[str, SubCategoryType] # Example: entities.all @@ -24,4 +24,4 @@ CategoryType = ( ) # Example: { entities: … } -PolicyType = Mapping[str, CategoryType] +type PolicyType = Mapping[str, CategoryType] diff --git a/homeassistant/auth/permissions/util.py b/homeassistant/auth/permissions/util.py index db85e18f60c..e1d1f660d75 100644 --- a/homeassistant/auth/permissions/util.py +++ b/homeassistant/auth/permissions/util.py @@ -10,8 +10,8 @@ from .const import SUBCAT_ALL from .models import PermissionLookup from .types import CategoryType, SubCategoryDict, ValueType -LookupFunc = Callable[[PermissionLookup, SubCategoryDict, str], ValueType | None] -SubCatLookupType = dict[str, LookupFunc] +type LookupFunc = Callable[[PermissionLookup, SubCategoryDict, str], ValueType | None] +type SubCatLookupType = dict[str, LookupFunc] def lookup_all( diff --git a/homeassistant/auth/providers/trusted_networks.py b/homeassistant/auth/providers/trusted_networks.py index 32d1934e093..564633073fc 100644 --- a/homeassistant/auth/providers/trusted_networks.py +++ b/homeassistant/auth/providers/trusted_networks.py @@ -28,8 +28,8 @@ from .. import InvalidAuthError from ..models import AuthFlowResult, Credentials, RefreshToken, UserMeta from . import AUTH_PROVIDER_SCHEMA, AUTH_PROVIDERS, AuthProvider, LoginFlow -IPAddress = IPv4Address | IPv6Address -IPNetwork = IPv4Network | IPv6Network +type IPAddress = IPv4Address | IPv6Address +type IPNetwork = IPv4Network | IPv6Network CONF_TRUSTED_NETWORKS = "trusted_networks" CONF_TRUSTED_USERS = "trusted_users" diff --git a/homeassistant/components/assist_pipeline/pipeline.py b/homeassistant/components/assist_pipeline/pipeline.py index 71b3d9f1592..2b4b306b68e 100644 --- a/homeassistant/components/assist_pipeline/pipeline.py +++ b/homeassistant/components/assist_pipeline/pipeline.py @@ -349,7 +349,7 @@ class PipelineEvent: timestamp: str = field(default_factory=lambda: dt_util.utcnow().isoformat()) -PipelineEventCallback = Callable[[PipelineEvent], None] +type PipelineEventCallback = Callable[[PipelineEvent], None] @dataclass(frozen=True) diff --git a/homeassistant/components/auth/__init__.py b/homeassistant/components/auth/__init__.py index fadc1c5e553..026935474f2 100644 --- a/homeassistant/components/auth/__init__.py +++ b/homeassistant/components/auth/__init__.py @@ -164,8 +164,8 @@ from . import indieauth, login_flow, mfa_setup_flow DOMAIN = "auth" STRICT_CONNECTION_URL = "/auth/strict_connection/temp_token" -StoreResultType = Callable[[str, Credentials], str] -RetrieveResultType = Callable[[str, str], Credentials | None] +type StoreResultType = Callable[[str, Credentials], str] +type RetrieveResultType = Callable[[str, str], Credentials | None] CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) diff --git a/homeassistant/components/bluetooth/models.py b/homeassistant/components/bluetooth/models.py index a97056e1f4b..deab0043097 100644 --- a/homeassistant/components/bluetooth/models.py +++ b/homeassistant/components/bluetooth/models.py @@ -8,5 +8,5 @@ from enum import Enum from home_assistant_bluetooth import BluetoothServiceInfoBleak BluetoothChange = Enum("BluetoothChange", "ADVERTISEMENT") -BluetoothCallback = Callable[[BluetoothServiceInfoBleak, BluetoothChange], None] -ProcessAdvertisementCallback = Callable[[BluetoothServiceInfoBleak], bool] +type BluetoothCallback = Callable[[BluetoothServiceInfoBleak, BluetoothChange], None] +type ProcessAdvertisementCallback = Callable[[BluetoothServiceInfoBleak], bool] diff --git a/homeassistant/components/calendar/trigger.py b/homeassistant/components/calendar/trigger.py index ad86ab1957d..523a634704c 100644 --- a/homeassistant/components/calendar/trigger.py +++ b/homeassistant/components/calendar/trigger.py @@ -88,8 +88,8 @@ class Timespan: return f"[{self.start}, {self.end})" -EventFetcher = Callable[[Timespan], Awaitable[list[CalendarEvent]]] -QueuedEventFetcher = Callable[[Timespan], Awaitable[list[QueuedCalendarEvent]]] +type EventFetcher = Callable[[Timespan], Awaitable[list[CalendarEvent]]] +type QueuedEventFetcher = Callable[[Timespan], Awaitable[list[QueuedCalendarEvent]]] def get_entity(hass: HomeAssistant, entity_id: str) -> CalendarEntity: diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 861b184975b..f8e8e6bf22b 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -335,7 +335,7 @@ def _get_camera_from_entity_id(hass: HomeAssistant, entity_id: str) -> Camera: # stream_id: A unique id for the stream, used to update an existing source # The output is the SDP answer, or None if the source or offer is not eligible. # The Callable may throw HomeAssistantError on failure. -RtspToWebRtcProviderType = Callable[[str, str, str], Awaitable[str | None]] +type RtspToWebRtcProviderType = Callable[[str, str, str], Awaitable[str | None]] def async_register_rtsp_to_web_rtc_provider( diff --git a/homeassistant/components/canary/sensor.py b/homeassistant/components/canary/sensor.py index 905214e0d1d..9aab4698bf3 100644 --- a/homeassistant/components/canary/sensor.py +++ b/homeassistant/components/canary/sensor.py @@ -21,7 +21,9 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DATA_COORDINATOR, DOMAIN, MANUFACTURER from .coordinator import CanaryDataUpdateCoordinator -SensorTypeItem = tuple[str, str | None, str | None, SensorDeviceClass | None, list[str]] +type SensorTypeItem = tuple[ + str, str | None, str | None, SensorDeviceClass | None, list[str] +] SENSOR_VALUE_PRECISION: Final = 2 ATTR_AIR_QUALITY: Final = "air_quality" diff --git a/homeassistant/components/configurator/__init__.py b/homeassistant/components/configurator/__init__.py index b2cf9a136cc..d1ddcb6cd4b 100644 --- a/homeassistant/components/configurator/__init__.py +++ b/homeassistant/components/configurator/__init__.py @@ -49,7 +49,7 @@ SERVICE_CONFIGURE = "configure" STATE_CONFIGURE = "configure" STATE_CONFIGURED = "configured" -ConfiguratorCallback = Callable[[list[dict[str, str]]], None] +type ConfiguratorCallback = Callable[[list[dict[str, str]]], None] CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) diff --git a/homeassistant/components/device_automation/__init__.py b/homeassistant/components/device_automation/__init__.py index 6d95d18214e..b79c9e56a95 100644 --- a/homeassistant/components/device_automation/__init__.py +++ b/homeassistant/components/device_automation/__init__.py @@ -9,7 +9,7 @@ from enum import Enum from functools import wraps import logging from types import ModuleType -from typing import TYPE_CHECKING, Any, Literal, TypeAlias, overload +from typing import TYPE_CHECKING, Any, Literal, overload import voluptuous as vol import voluptuous_serialize @@ -49,7 +49,7 @@ if TYPE_CHECKING: from .condition import DeviceAutomationConditionProtocol from .trigger import DeviceAutomationTriggerProtocol - DeviceAutomationPlatformType: TypeAlias = ( + type DeviceAutomationPlatformType = ( ModuleType | DeviceAutomationTriggerProtocol | DeviceAutomationConditionProtocol diff --git a/homeassistant/components/dlna_dmr/config_flow.py b/homeassistant/components/dlna_dmr/config_flow.py index 837bfc456d8..7d9efc4096c 100644 --- a/homeassistant/components/dlna_dmr/config_flow.py +++ b/homeassistant/components/dlna_dmr/config_flow.py @@ -40,7 +40,7 @@ from .data import get_domain_data LOGGER = logging.getLogger(__name__) -FlowInput = Mapping[str, Any] | None +type FlowInput = Mapping[str, Any] | None class ConnectError(IntegrationError): diff --git a/homeassistant/components/energy/data.py b/homeassistant/components/energy/data.py index d0da07da37c..9c5a9fbacd1 100644 --- a/homeassistant/components/energy/data.py +++ b/homeassistant/components/energy/data.py @@ -121,7 +121,7 @@ class WaterSourceType(TypedDict): number_energy_price: float | None # Price for energy ($/m³) -SourceType = ( +type SourceType = ( GridSourceType | SolarSourceType | BatterySourceType diff --git a/homeassistant/components/energy/types.py b/homeassistant/components/energy/types.py index d52a15a60c8..96b122da839 100644 --- a/homeassistant/components/energy/types.py +++ b/homeassistant/components/energy/types.py @@ -14,8 +14,8 @@ class SolarForecastType(TypedDict): wh_hours: dict[str, float | int] -GetSolarForecastType = Callable[ - [HomeAssistant, str], Awaitable["SolarForecastType | None"] +type GetSolarForecastType = Callable[ + [HomeAssistant, str], Awaitable[SolarForecastType | None] ] diff --git a/homeassistant/components/energy/websocket_api.py b/homeassistant/components/energy/websocket_api.py index 38cd87a22f5..4135c49bf8b 100644 --- a/homeassistant/components/energy/websocket_api.py +++ b/homeassistant/components/energy/websocket_api.py @@ -33,12 +33,12 @@ from .data import ( from .types import EnergyPlatform, GetSolarForecastType, SolarForecastType from .validate import async_validate -EnergyWebSocketCommandHandler = Callable[ - [HomeAssistant, websocket_api.ActiveConnection, "dict[str, Any]", "EnergyManager"], +type EnergyWebSocketCommandHandler = Callable[ + [HomeAssistant, websocket_api.ActiveConnection, dict[str, Any], EnergyManager], None, ] -AsyncEnergyWebSocketCommandHandler = Callable[ - [HomeAssistant, websocket_api.ActiveConnection, "dict[str, Any]", "EnergyManager"], +type AsyncEnergyWebSocketCommandHandler = Callable[ + [HomeAssistant, websocket_api.ActiveConnection, dict[str, Any], EnergyManager], Awaitable[None], ] diff --git a/homeassistant/components/firmata/board.py b/homeassistant/components/firmata/board.py index 9573627e130..641a0a74fa7 100644 --- a/homeassistant/components/firmata/board.py +++ b/homeassistant/components/firmata/board.py @@ -30,7 +30,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -FirmataPinType = int | str +type FirmataPinType = int | str class FirmataBoard: diff --git a/homeassistant/components/fronius/const.py b/homeassistant/components/fronius/const.py index 8702339ef03..083085270e0 100644 --- a/homeassistant/components/fronius/const.py +++ b/homeassistant/components/fronius/const.py @@ -8,7 +8,7 @@ from homeassistant.helpers.typing import StateType DOMAIN: Final = "fronius" -SolarNetId = str +type SolarNetId = str SOLAR_NET_DISCOVERY_NEW: Final = "fronius_discovery_new" SOLAR_NET_ID_POWER_FLOW: SolarNetId = "power_flow" SOLAR_NET_ID_SYSTEM: SolarNetId = "system" diff --git a/homeassistant/components/greeneye_monitor/sensor.py b/homeassistant/components/greeneye_monitor/sensor.py index d9ab6b16960..04464fe2567 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -115,7 +115,7 @@ async def async_setup_platform( on_new_monitor(monitor) -UnderlyingSensorType = ( +type UnderlyingSensorType = ( greeneye.monitor.Channel | greeneye.monitor.PulseCounter | greeneye.monitor.TemperatureSensor diff --git a/homeassistant/components/harmony/subscriber.py b/homeassistant/components/harmony/subscriber.py index e923df82843..ec42c47f9ff 100644 --- a/homeassistant/components/harmony/subscriber.py +++ b/homeassistant/components/harmony/subscriber.py @@ -10,8 +10,8 @@ from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback _LOGGER = logging.getLogger(__name__) -NoParamCallback = HassJob[[], Any] | None -ActivityCallback = HassJob[[tuple], Any] | None +type NoParamCallback = HassJob[[], Any] | None +type ActivityCallback = HassJob[[tuple], Any] | None class HarmonyCallback(NamedTuple): diff --git a/homeassistant/components/homekit_controller/connection.py b/homeassistant/components/homekit_controller/connection.py index 78190634aff..2479dc3c181 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -57,9 +57,9 @@ BLE_AVAILABILITY_CHECK_INTERVAL = 1800 # seconds _LOGGER = logging.getLogger(__name__) -AddAccessoryCb = Callable[[Accessory], bool] -AddServiceCb = Callable[[Service], bool] -AddCharacteristicCb = Callable[[Characteristic], bool] +type AddAccessoryCb = Callable[[Accessory], bool] +type AddServiceCb = Callable[[Service], bool] +type AddCharacteristicCb = Callable[[Characteristic], bool] def valid_serial_number(serial: str) -> bool: diff --git a/homeassistant/components/homekit_controller/utils.py b/homeassistant/components/homekit_controller/utils.py index 2f94f5bac92..ac436ce27a4 100644 --- a/homeassistant/components/homekit_controller/utils.py +++ b/homeassistant/components/homekit_controller/utils.py @@ -12,7 +12,7 @@ from homeassistant.core import Event, HomeAssistant from .const import CONTROLLER from .storage import async_get_entity_storage -IidTuple = tuple[int, int | None, int | None] +type IidTuple = tuple[int, int | None, int | None] def unique_id_to_iids(unique_id: str) -> IidTuple | None: diff --git a/homeassistant/components/huawei_lte/device_tracker.py b/homeassistant/components/huawei_lte/device_tracker.py index 1f9905f4e9c..0e35208dcce 100644 --- a/homeassistant/components/huawei_lte/device_tracker.py +++ b/homeassistant/components/huawei_lte/device_tracker.py @@ -34,7 +34,7 @@ _LOGGER = logging.getLogger(__name__) _DEVICE_SCAN = f"{DEVICE_TRACKER_DOMAIN}/device_scan" -_HostType = dict[str, Any] +type _HostType = dict[str, Any] def _get_hosts( diff --git a/homeassistant/components/hue/v2/binary_sensor.py b/homeassistant/components/hue/v2/binary_sensor.py index bc650569a63..650a9384e35 100644 --- a/homeassistant/components/hue/v2/binary_sensor.py +++ b/homeassistant/components/hue/v2/binary_sensor.py @@ -3,7 +3,6 @@ from __future__ import annotations from functools import partial -from typing import TypeAlias from aiohue.v2 import HueBridgeV2 from aiohue.v2.controllers.config import ( @@ -37,10 +36,8 @@ from ..bridge import HueBridge from ..const import DOMAIN from .entity import HueBaseEntity -SensorType: TypeAlias = ( - CameraMotion | Contact | Motion | EntertainmentConfiguration | Tamper -) -ControllerType: TypeAlias = ( +type SensorType = CameraMotion | Contact | Motion | EntertainmentConfiguration | Tamper +type ControllerType = ( CameraMotionController | ContactController | MotionController diff --git a/homeassistant/components/hue/v2/entity.py b/homeassistant/components/hue/v2/entity.py index 8aeac4d8180..a7861ebd7b4 100644 --- a/homeassistant/components/hue/v2/entity.py +++ b/homeassistant/components/hue/v2/entity.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, TypeAlias +from typing import TYPE_CHECKING from aiohue.v2.controllers.base import BaseResourcesController from aiohue.v2.controllers.events import EventType @@ -24,7 +24,7 @@ if TYPE_CHECKING: from aiohue.v2.models.light_level import LightLevel from aiohue.v2.models.motion import Motion - HueResource: TypeAlias = Light | DevicePower | GroupedLight | LightLevel | Motion + type HueResource = Light | DevicePower | GroupedLight | LightLevel | Motion RESOURCE_TYPE_NAMES = { diff --git a/homeassistant/components/hue/v2/sensor.py b/homeassistant/components/hue/v2/sensor.py index e46ca561964..6e90d3ca775 100644 --- a/homeassistant/components/hue/v2/sensor.py +++ b/homeassistant/components/hue/v2/sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations from functools import partial -from typing import Any, TypeAlias +from typing import Any from aiohue.v2 import HueBridgeV2 from aiohue.v2.controllers.events import EventType @@ -34,8 +34,8 @@ from ..bridge import HueBridge from ..const import DOMAIN from .entity import HueBaseEntity -SensorType: TypeAlias = DevicePower | LightLevel | Temperature | ZigbeeConnectivity -ControllerType: TypeAlias = ( +type SensorType = DevicePower | LightLevel | Temperature | ZigbeeConnectivity +type ControllerType = ( DevicePowerController | LightLevelController | TemperatureController diff --git a/homeassistant/components/intent/timers.py b/homeassistant/components/intent/timers.py index 5ade839aacd..e653ccfa930 100644 --- a/homeassistant/components/intent/timers.py +++ b/homeassistant/components/intent/timers.py @@ -140,7 +140,7 @@ class TimerEventType(StrEnum): """Timer finished without being cancelled.""" -TimerHandler = Callable[[TimerEventType, TimerInfo], None] +type TimerHandler = Callable[[TimerEventType, TimerInfo], None] class TimerNotFoundError(intent.IntentHandleError): diff --git a/homeassistant/components/knx/const.py b/homeassistant/components/knx/const.py index 9c0d5e1125a..67e009cacfc 100644 --- a/homeassistant/components/knx/const.py +++ b/homeassistant/components/knx/const.py @@ -86,8 +86,8 @@ ATTR_SOURCE: Final = "source" # dispatcher signal for KNX interface device triggers SIGNAL_KNX_TELEGRAM_DICT: Final = "knx_telegram_dict" -AsyncMessageCallbackType = Callable[[Telegram], Awaitable[None]] -MessageCallbackType = Callable[[Telegram], None] +type AsyncMessageCallbackType = Callable[[Telegram], Awaitable[None]] +type MessageCallbackType = Callable[[Telegram], None] SERVICE_KNX_SEND: Final = "send" SERVICE_KNX_ATTR_PAYLOAD: Final = "payload" diff --git a/homeassistant/components/kraken/const.py b/homeassistant/components/kraken/const.py index 3b1bc29c7cd..9fbad46dd4b 100644 --- a/homeassistant/components/kraken/const.py +++ b/homeassistant/components/kraken/const.py @@ -19,7 +19,7 @@ class KrakenResponseEntry(TypedDict): opening_price: float -KrakenResponse = dict[str, KrakenResponseEntry] +type KrakenResponse = dict[str, KrakenResponseEntry] DEFAULT_SCAN_INTERVAL = 60 diff --git a/homeassistant/components/lcn/helpers.py b/homeassistant/components/lcn/helpers.py index b0b1a2f1c04..d46628fc6da 100644 --- a/homeassistant/components/lcn/helpers.py +++ b/homeassistant/components/lcn/helpers.py @@ -6,7 +6,7 @@ import asyncio from copy import deepcopy from itertools import chain import re -from typing import TypeAlias, cast +from typing import cast import pypck import voluptuous as vol @@ -60,12 +60,10 @@ from .const import ( ) # typing -AddressType = tuple[int, int, bool] -DeviceConnectionType: TypeAlias = ( - pypck.module.ModuleConnection | pypck.module.GroupConnection -) +type AddressType = tuple[int, int, bool] +type DeviceConnectionType = pypck.module.ModuleConnection | pypck.module.GroupConnection -InputType = type[pypck.inputs.Input] +type InputType = type[pypck.inputs.Input] # Regex for address validation PATTERN_ADDRESS = re.compile( diff --git a/homeassistant/components/matter/models.py b/homeassistant/components/matter/models.py index 18e503523ae..c10219d8a33 100644 --- a/homeassistant/components/matter/models.py +++ b/homeassistant/components/matter/models.py @@ -13,7 +13,7 @@ from matter_server.client.models.node import MatterEndpoint from homeassistant.const import Platform from homeassistant.helpers.entity import EntityDescription -SensorValueTypes = type[ +type SensorValueTypes = type[ clusters.uint | int | clusters.Nullable | clusters.float32 | float ] diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 4c435adda7d..6c70b39c964 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -467,7 +467,7 @@ async def websocket_subscribe( connection.send_message(websocket_api.result_message(msg["id"])) -ConnectionStatusCallback = Callable[[bool], None] +type ConnectionStatusCallback = Callable[[bool], None] @callback diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index 02998f5d6dd..57aa8a11686 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -99,9 +99,9 @@ UNSUBSCRIBE_COOLDOWN = 0.1 TIMEOUT_ACK = 10 RECONNECT_INTERVAL_SECONDS = 10 -SocketType = socket.socket | ssl.SSLSocket | Any +type SocketType = socket.socket | ssl.SSLSocket | Any -SubscribePayloadType = str | bytes # Only bytes if encoding is None +type SubscribePayloadType = str | bytes # Only bytes if encoding is None def publish( diff --git a/homeassistant/components/mqtt/models.py b/homeassistant/components/mqtt/models.py index bba543893c9..eda26f2559e 100644 --- a/homeassistant/components/mqtt/models.py +++ b/homeassistant/components/mqtt/models.py @@ -44,7 +44,7 @@ _LOGGER = logging.getLogger(__name__) ATTR_THIS = "this" -PublishPayloadType = str | bytes | int | float | None +type PublishPayloadType = str | bytes | int | float | None @dataclass @@ -69,8 +69,8 @@ class ReceiveMessage: timestamp: float -AsyncMessageCallbackType = Callable[[ReceiveMessage], Coroutine[Any, Any, None]] -MessageCallbackType = Callable[[ReceiveMessage], None] +type AsyncMessageCallbackType = Callable[[ReceiveMessage], Coroutine[Any, Any, None]] +type MessageCallbackType = Callable[[ReceiveMessage], None] class SubscriptionDebugInfo(TypedDict): diff --git a/homeassistant/components/mysensors/const.py b/homeassistant/components/mysensors/const.py index 3885a2d7a0e..a65b46616d3 100644 --- a/homeassistant/components/mysensors/const.py +++ b/homeassistant/components/mysensors/const.py @@ -19,7 +19,7 @@ CONF_TOPIC_IN_PREFIX: Final = "topic_in_prefix" CONF_TOPIC_OUT_PREFIX: Final = "topic_out_prefix" CONF_VERSION: Final = "version" CONF_GATEWAY_TYPE: Final = "gateway_type" -ConfGatewayType = Literal["Serial", "TCP", "MQTT"] +type ConfGatewayType = Literal["Serial", "TCP", "MQTT"] CONF_GATEWAY_TYPE_SERIAL: ConfGatewayType = "Serial" CONF_GATEWAY_TYPE_TCP: ConfGatewayType = "TCP" CONF_GATEWAY_TYPE_MQTT: ConfGatewayType = "MQTT" @@ -55,16 +55,16 @@ class NodeDiscoveryInfo(TypedDict): SERVICE_SEND_IR_CODE: Final = "send_ir_code" -SensorType = str +type SensorType = str # S_DOOR, S_MOTION, S_SMOKE, ... -ValueType = str +type ValueType = str # V_TRIPPED, V_ARMED, V_STATUS, V_PERCENTAGE, ... -GatewayId = str +type GatewayId = str # a unique id generated by config_flow.py and stored in the ConfigEntry as the entry id. -DevId = tuple[GatewayId, int, int, int] +type DevId = tuple[GatewayId, int, int, int] # describes the backend of a hass entity. # Contents are: GatewayId, node_id, child_id, v_type as int # diff --git a/homeassistant/components/plugwise/const.py b/homeassistant/components/plugwise/const.py index 975ddae346a..ed8cb2d2002 100644 --- a/homeassistant/components/plugwise/const.py +++ b/homeassistant/components/plugwise/const.py @@ -37,19 +37,19 @@ ZEROCONF_MAP: Final[dict[str, str]] = { "stretch": "Stretch", } -NumberType = Literal[ +type NumberType = Literal[ "maximum_boiler_temperature", "max_dhw_temperature", "temperature_offset", ] -SelectType = Literal[ +type SelectType = Literal[ "select_dhw_mode", "select_gateway_mode", "select_regulation_mode", "select_schedule", ] -SelectOptionsType = Literal[ +type SelectOptionsType = Literal[ "dhw_modes", "gateway_modes", "regulation_modes", diff --git a/homeassistant/components/private_ble_device/coordinator.py b/homeassistant/components/private_ble_device/coordinator.py index 69db399a454..3e7bafed748 100644 --- a/homeassistant/components/private_ble_device/coordinator.py +++ b/homeassistant/components/private_ble_device/coordinator.py @@ -17,8 +17,8 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -UnavailableCallback = Callable[[bluetooth.BluetoothServiceInfoBleak], None] -Cancellable = Callable[[], None] +type UnavailableCallback = Callable[[bluetooth.BluetoothServiceInfoBleak], None] +type Cancellable = Callable[[], None] def async_last_service_info( diff --git a/homeassistant/components/roku/browse_media.py b/homeassistant/components/roku/browse_media.py index 1ac37f10eb9..09affe4369b 100644 --- a/homeassistant/components/roku/browse_media.py +++ b/homeassistant/components/roku/browse_media.py @@ -40,7 +40,7 @@ EXPANDABLE_MEDIA_TYPES = [ MediaType.CHANNELS, ] -GetBrowseImageUrlType = Callable[[str, str, "str | None"], str | None] +type GetBrowseImageUrlType = Callable[[str, str, str | None], str | None] def get_thumbnail_url_full( diff --git a/homeassistant/components/screenlogic/const.py b/homeassistant/components/screenlogic/const.py index 31e8468240f..a40b5415fe3 100644 --- a/homeassistant/components/screenlogic/const.py +++ b/homeassistant/components/screenlogic/const.py @@ -15,7 +15,7 @@ from homeassistant.const import ( ) from homeassistant.util import slugify -ScreenLogicDataPath = tuple[str | int, ...] +type ScreenLogicDataPath = tuple[str | int, ...] DOMAIN = "screenlogic" DEFAULT_SCAN_INTERVAL = 30 diff --git a/homeassistant/components/senz/__init__.py b/homeassistant/components/senz/__init__.py index d40b485bf89..288bf005a5c 100644 --- a/homeassistant/components/senz/__init__.py +++ b/homeassistant/components/senz/__init__.py @@ -30,7 +30,7 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) PLATFORMS = [Platform.CLIMATE] -SENZDataUpdateCoordinator = DataUpdateCoordinator[dict[str, Thermostat]] +type SENZDataUpdateCoordinator = DataUpdateCoordinator[dict[str, Thermostat]] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/simplisafe/typing.py b/homeassistant/components/simplisafe/typing.py index 5651a3072b9..712cc59903d 100644 --- a/homeassistant/components/simplisafe/typing.py +++ b/homeassistant/components/simplisafe/typing.py @@ -3,4 +3,4 @@ from simplipy.system.v2 import SystemV2 from simplipy.system.v3 import SystemV3 -SystemType = SystemV2 | SystemV3 +type SystemType = SystemV2 | SystemV3 diff --git a/homeassistant/components/sonos/media_browser.py b/homeassistant/components/sonos/media_browser.py index eeadd7db232..498607c5465 100644 --- a/homeassistant/components/sonos/media_browser.py +++ b/homeassistant/components/sonos/media_browser.py @@ -43,7 +43,7 @@ from .speaker import SonosMedia, SonosSpeaker _LOGGER = logging.getLogger(__name__) -GetBrowseImageUrlType = Callable[[str, str, "str | None"], str] +type GetBrowseImageUrlType = Callable[[str, str, str | None], str] def get_thumbnail_url_full( diff --git a/homeassistant/components/sonos/number.py b/homeassistant/components/sonos/number.py index f9e9fc8bee0..272218cc01e 100644 --- a/homeassistant/components/sonos/number.py +++ b/homeassistant/components/sonos/number.py @@ -28,7 +28,7 @@ LEVEL_TYPES = { "music_surround_level": (-15, 15), } -SocoFeatures = list[tuple[str, tuple[int, int]]] +type SocoFeatures = list[tuple[str, tuple[int, int]]] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/ssdp/__init__.py b/homeassistant/components/ssdp/__init__.py index 27d96d6ff09..17c35179326 100644 --- a/homeassistant/components/ssdp/__init__.py +++ b/homeassistant/components/ssdp/__init__.py @@ -126,7 +126,7 @@ class SsdpServiceInfo(BaseServiceInfo): SsdpChange = Enum("SsdpChange", "ALIVE BYEBYE UPDATE") -SsdpHassJobCallback = HassJob[ +type SsdpHassJobCallback = HassJob[ [SsdpServiceInfo, SsdpChange], Coroutine[Any, Any, None] | None ] diff --git a/homeassistant/components/switchbot_cloud/coordinator.py b/homeassistant/components/switchbot_cloud/coordinator.py index 7d3980bcff9..0ebd04f7e5a 100644 --- a/homeassistant/components/switchbot_cloud/coordinator.py +++ b/homeassistant/components/switchbot_cloud/coordinator.py @@ -13,7 +13,7 @@ from .const import DEFAULT_SCAN_INTERVAL, DOMAIN _LOGGER = getLogger(__name__) -Status = dict[str, Any] | None +type Status = dict[str, Any] | None class SwitchBotCoordinator(DataUpdateCoordinator[Status]): diff --git a/homeassistant/components/system_log/__init__.py b/homeassistant/components/system_log/__init__.py index 369ca283495..0749f87a67f 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -19,7 +19,7 @@ from homeassistant.core import Event, HomeAssistant, ServiceCall, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType -KeyType = tuple[str, tuple[str, int], tuple[str, int, str] | None] +type KeyType = tuple[str, tuple[str, int], tuple[str, int, str] | None] CONF_MAX_ENTRIES = "max_entries" CONF_FIRE_EVENT = "fire_event" diff --git a/homeassistant/components/tasmota/discovery.py b/homeassistant/components/tasmota/discovery.py index 5d70330dbdf..92fcbcc7fc4 100644 --- a/homeassistant/components/tasmota/discovery.py +++ b/homeassistant/components/tasmota/discovery.py @@ -45,7 +45,7 @@ TASMOTA_DISCOVERY_INSTANCE = "tasmota_discovery_instance" MQTT_TOPIC_URL = "https://tasmota.github.io/docs/Home-Assistant/#tasmota-integration" -SetupDeviceCallback = Callable[[TasmotaDeviceConfig, str], Awaitable[None]] +type SetupDeviceCallback = Callable[[TasmotaDeviceConfig, str], Awaitable[None]] def clear_discovery_hash( diff --git a/homeassistant/components/tod/binary_sensor.py b/homeassistant/components/tod/binary_sensor.py index c35f92fd27f..8e44c7e57d3 100644 --- a/homeassistant/components/tod/binary_sensor.py +++ b/homeassistant/components/tod/binary_sensor.py @@ -36,7 +36,7 @@ from .const import ( CONF_BEFORE_TIME, ) -SunEventType = Literal["sunrise", "sunset"] +type SunEventType = Literal["sunrise", "sunset"] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/traccar_server/coordinator.py b/homeassistant/components/traccar_server/coordinator.py index 3d44b1ecede..95ce42469f1 100644 --- a/homeassistant/components/traccar_server/coordinator.py +++ b/homeassistant/components/traccar_server/coordinator.py @@ -35,7 +35,7 @@ class TraccarServerCoordinatorDataDevice(TypedDict): attributes: dict[str, Any] -TraccarServerCoordinatorData = dict[int, TraccarServerCoordinatorDataDevice] +type TraccarServerCoordinatorData = dict[int, TraccarServerCoordinatorDataDevice] class TraccarServerCoordinator(DataUpdateCoordinator[TraccarServerCoordinatorData]): diff --git a/homeassistant/components/trace/__init__.py b/homeassistant/components/trace/__init__.py index 6193f06ff4f..79830e0b63f 100644 --- a/homeassistant/components/trace/__init__.py +++ b/homeassistant/components/trace/__init__.py @@ -40,7 +40,7 @@ TRACE_CONFIG_SCHEMA = { CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) -TraceData = dict[str, LimitedSizeDict[str, BaseTrace]] +type TraceData = dict[str, LimitedSizeDict[str, BaseTrace]] @callback diff --git a/homeassistant/components/tts/const.py b/homeassistant/components/tts/const.py index 99015512498..ab22a44cab6 100644 --- a/homeassistant/components/tts/const.py +++ b/homeassistant/components/tts/const.py @@ -18,4 +18,4 @@ DOMAIN = "tts" DATA_TTS_MANAGER = "tts_manager" -TtsAudioType = tuple[str | None, bytes | None] +type TtsAudioType = tuple[str | None, bytes | None] diff --git a/homeassistant/components/unifiprotect/data.py b/homeassistant/components/unifiprotect/data.py index 6c5a1472015..b64a08749d5 100644 --- a/homeassistant/components/unifiprotect/data.py +++ b/homeassistant/components/unifiprotect/data.py @@ -43,7 +43,7 @@ from .const import ( from .utils import async_dispatch_id as _ufpd, async_get_devices_by_type _LOGGER = logging.getLogger(__name__) -ProtectDeviceType = ProtectAdoptableDeviceModel | NVR +type ProtectDeviceType = ProtectAdoptableDeviceModel | NVR @callback diff --git a/homeassistant/components/websocket_api/connection.py b/homeassistant/components/websocket_api/connection.py index bd2eb9ff59c..ef70df4a123 100644 --- a/homeassistant/components/websocket_api/connection.py +++ b/homeassistant/components/websocket_api/connection.py @@ -26,8 +26,8 @@ current_connection = ContextVar["ActiveConnection | None"]( "current_connection", default=None ) -MessageHandler = Callable[[HomeAssistant, "ActiveConnection", dict[str, Any]], None] -BinaryHandler = Callable[[HomeAssistant, "ActiveConnection", bytes], None] +type MessageHandler = Callable[[HomeAssistant, ActiveConnection, dict[str, Any]], None] +type BinaryHandler = Callable[[HomeAssistant, ActiveConnection, bytes], None] class ActiveConnection: diff --git a/homeassistant/components/websocket_api/const.py b/homeassistant/components/websocket_api/const.py index 25d3ff8dcb3..3a81508addc 100644 --- a/homeassistant/components/websocket_api/const.py +++ b/homeassistant/components/websocket_api/const.py @@ -11,11 +11,11 @@ if TYPE_CHECKING: from .connection import ActiveConnection -WebSocketCommandHandler = Callable[ - [HomeAssistant, "ActiveConnection", dict[str, Any]], None +type WebSocketCommandHandler = Callable[ + [HomeAssistant, ActiveConnection, dict[str, Any]], None ] -AsyncWebSocketCommandHandler = Callable[ - [HomeAssistant, "ActiveConnection", dict[str, Any]], Awaitable[None] +type AsyncWebSocketCommandHandler = Callable[ + [HomeAssistant, ActiveConnection, dict[str, Any]], Awaitable[None] ] DOMAIN: Final = "websocket_api" diff --git a/homeassistant/components/wemo/__init__.py b/homeassistant/components/wemo/__init__.py index 822bf65fdc4..3ef7ac92f98 100644 --- a/homeassistant/components/wemo/__init__.py +++ b/homeassistant/components/wemo/__init__.py @@ -44,8 +44,8 @@ WEMO_MODEL_DISPATCH = { _LOGGER = logging.getLogger(__name__) -DispatchCallback = Callable[[DeviceCoordinator], Coroutine[Any, Any, None]] -HostPortTuple = tuple[str, int | None] +type DispatchCallback = Callable[[DeviceCoordinator], Coroutine[Any, Any, None]] +type HostPortTuple = tuple[str, int | None] def coerce_host_port(value: str) -> HostPortTuple: diff --git a/homeassistant/components/wemo/coordinator.py b/homeassistant/components/wemo/coordinator.py index 3e8d87d6300..9bedd12f54b 100644 --- a/homeassistant/components/wemo/coordinator.py +++ b/homeassistant/components/wemo/coordinator.py @@ -37,9 +37,9 @@ from .models import async_wemo_data _LOGGER = logging.getLogger(__name__) # Literal values must match options.error keys from strings.json. -ErrorStringKey = Literal["long_press_requires_subscription"] +type ErrorStringKey = Literal["long_press_requires_subscription"] # Literal values must match options.step.init.data keys from strings.json. -OptionsFieldKey = Literal["enable_subscription", "enable_long_press"] +type OptionsFieldKey = Literal["enable_subscription", "enable_long_press"] class OptionsValidationError(Exception): diff --git a/homeassistant/components/zha/core/const.py b/homeassistant/components/zha/core/const.py index 74110d390ed..2359fe0a1c3 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -245,7 +245,7 @@ ZHA_CONFIG_SCHEMAS = { ZHA_ALARM_OPTIONS: CONF_ZHA_ALARM_SCHEMA, } -_ControllerClsType = type[zigpy.application.ControllerApplication] +type _ControllerClsType = type[zigpy.application.ControllerApplication] class RadioType(enum.Enum): diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index 009364ba9d2..8b8826e2648 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -96,7 +96,7 @@ if TYPE_CHECKING: from ..entity import ZhaEntity from .cluster_handlers import ClusterHandler - _LogFilterType = Filter | Callable[[LogRecord], bool] + type _LogFilterType = Filter | Callable[[LogRecord], bool] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 661515758de..14dcc9d4755 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -238,7 +238,9 @@ class OperationNotAllowed(ConfigError): """Raised when a config entry operation is not allowed.""" -UpdateListenerType = Callable[[HomeAssistant, "ConfigEntry"], Coroutine[Any, Any, None]] +type UpdateListenerType = Callable[ + [HomeAssistant, ConfigEntry], Coroutine[Any, Any, None] +] FROZEN_CONFIG_ENTRY_ATTRS = { "entry_id", diff --git a/homeassistant/core.py b/homeassistant/core.py index 8c08a0198b0..9be67cbfab7 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -141,7 +141,7 @@ _UNDEF: dict[Any, Any] = {} _SENTINEL = object() _CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) _DataT = TypeVar("_DataT", bound=Mapping[str, Any], default=Mapping[str, Any]) -CALLBACK_TYPE = Callable[[], None] +type CALLBACK_TYPE = Callable[[], None] CORE_STORAGE_KEY = "core.config" CORE_STORAGE_VERSION = 1 @@ -152,8 +152,8 @@ DOMAIN = "homeassistant" # How long to wait to log tasks that are blocking BLOCK_LOG_TIMEOUT = 60 -ServiceResponse = JsonObjectType | None -EntityServiceResponse = dict[str, ServiceResponse] +type ServiceResponse = JsonObjectType | None +type EntityServiceResponse = dict[str, ServiceResponse] class ConfigSource(enum.StrEnum): diff --git a/homeassistant/helpers/category_registry.py b/homeassistant/helpers/category_registry.py index 5b22b6d8051..6498859e2ab 100644 --- a/homeassistant/helpers/category_registry.py +++ b/homeassistant/helpers/category_registry.py @@ -47,7 +47,7 @@ class EventCategoryRegistryUpdatedData(TypedDict): category_id: str -EventCategoryRegistryUpdated = Event[EventCategoryRegistryUpdatedData] +type EventCategoryRegistryUpdated = Event[EventCategoryRegistryUpdatedData] @dataclass(slots=True, kw_only=True, frozen=True) diff --git a/homeassistant/helpers/collection.py b/homeassistant/helpers/collection.py index 6e833e338db..da6d3d65b54 100644 --- a/homeassistant/helpers/collection.py +++ b/homeassistant/helpers/collection.py @@ -55,7 +55,7 @@ class CollectionChangeSet: item: Any -ChangeListener = Callable[ +type ChangeListener = Callable[ [ # Change type str, @@ -67,7 +67,7 @@ ChangeListener = Callable[ Awaitable[None], ] -ChangeSetListener = Callable[[Iterable[CollectionChangeSet]], Awaitable[None]] +type ChangeSetListener = Callable[[Iterable[CollectionChangeSet]], Awaitable[None]] class CollectionError(HomeAssistantError): diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index e76244240d1..3959a2147bd 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -115,7 +115,7 @@ class ConditionProtocol(Protocol): """Evaluate state based on configuration.""" -ConditionCheckerType = Callable[[HomeAssistant, TemplateVarsType], bool | None] +type ConditionCheckerType = Callable[[HomeAssistant, TemplateVarsType], bool | None] def condition_trace_append(variables: TemplateVarsType, path: str) -> TraceElement: diff --git a/homeassistant/helpers/device_registry.py b/homeassistant/helpers/device_registry.py index a0bfc751a12..51896ac2be9 100644 --- a/homeassistant/helpers/device_registry.py +++ b/homeassistant/helpers/device_registry.py @@ -160,7 +160,7 @@ class _EventDeviceRegistryUpdatedData_Update(TypedDict): changes: dict[str, Any] -EventDeviceRegistryUpdatedData = ( +type EventDeviceRegistryUpdatedData = ( _EventDeviceRegistryUpdatedData_CreateRemove | _EventDeviceRegistryUpdatedData_Update ) diff --git a/homeassistant/helpers/entity_registry.py b/homeassistant/helpers/entity_registry.py index 81454db57a7..2964c55af74 100644 --- a/homeassistant/helpers/entity_registry.py +++ b/homeassistant/helpers/entity_registry.py @@ -134,14 +134,14 @@ class _EventEntityRegistryUpdatedData_Update(TypedDict): old_entity_id: NotRequired[str] -EventEntityRegistryUpdatedData = ( +type EventEntityRegistryUpdatedData = ( _EventEntityRegistryUpdatedData_CreateRemove | _EventEntityRegistryUpdatedData_Update ) -EntityOptionsType = Mapping[str, Mapping[str, Any]] -ReadOnlyEntityOptionsType = ReadOnlyDict[str, ReadOnlyDict[str, Any]] +type EntityOptionsType = Mapping[str, Mapping[str, Any]] +type ReadOnlyEntityOptionsType = ReadOnlyDict[str, ReadOnlyDict[str, Any]] DISPLAY_DICT_OPTIONAL = ( # key, attr_name, convert_to_list diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 0a2a8a93461..c54af93d320 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -1262,7 +1262,7 @@ class TrackTemplateResultInfo: self.hass.async_run_hass_job(self._job, event, updates) -TrackTemplateResultListener = Callable[ +type TrackTemplateResultListener = Callable[ [ Event[EventStateChangedData] | None, list[TrackTemplateResult], diff --git a/homeassistant/helpers/floor_registry.py b/homeassistant/helpers/floor_registry.py index 6980fdc98c0..9bf8a2a5d26 100644 --- a/homeassistant/helpers/floor_registry.py +++ b/homeassistant/helpers/floor_registry.py @@ -53,7 +53,7 @@ class EventFloorRegistryUpdatedData(TypedDict): floor_id: str -EventFloorRegistryUpdated = Event[EventFloorRegistryUpdatedData] +type EventFloorRegistryUpdated = Event[EventFloorRegistryUpdatedData] @dataclass(slots=True, kw_only=True, frozen=True) diff --git a/homeassistant/helpers/http.py b/homeassistant/helpers/http.py index a464056fc07..bbe4e26f4e5 100644 --- a/homeassistant/helpers/http.py +++ b/homeassistant/helpers/http.py @@ -30,7 +30,7 @@ from .json import find_paths_unserializable_data, json_bytes, json_dumps _LOGGER = logging.getLogger(__name__) -AllowCorsType = Callable[[AbstractRoute | AbstractResource], None] +type AllowCorsType = Callable[[AbstractRoute | AbstractResource], None] KEY_AUTHENTICATED: Final = "ha_authenticated" KEY_ALLOW_ALL_CORS = AppKey[AllowCorsType]("allow_all_cors") KEY_ALLOW_CONFIGRED_CORS = AppKey[AllowCorsType]("allow_configured_cors") diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 8b8ea805153..3a616b5e29c 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -35,7 +35,7 @@ from . import ( ) _LOGGER = logging.getLogger(__name__) -_SlotsType = dict[str, Any] +type _SlotsType = dict[str, Any] INTENT_TURN_OFF = "HassTurnOff" INTENT_TURN_ON = "HassTurnOn" diff --git a/homeassistant/helpers/label_registry.py b/homeassistant/helpers/label_registry.py index d4150f0a3bb..64e884e1428 100644 --- a/homeassistant/helpers/label_registry.py +++ b/homeassistant/helpers/label_registry.py @@ -53,7 +53,7 @@ class EventLabelRegistryUpdatedData(TypedDict): label_id: str -EventLabelRegistryUpdated = Event[EventLabelRegistryUpdatedData] +type EventLabelRegistryUpdated = Event[EventLabelRegistryUpdatedData] @dataclass(slots=True, frozen=True, kw_only=True) diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 94e7f3325fb..7af29fb4327 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -1311,7 +1311,7 @@ async def _async_stop_scripts_at_shutdown(hass: HomeAssistant, event: Event) -> ) -_VarsType = dict[str, Any] | MappingProxyType +type _VarsType = dict[str, Any] | MappingProxyType def _referenced_extract_ids(data: Any, key: str, found: set[str]) -> None: diff --git a/homeassistant/helpers/service_info/mqtt.py b/homeassistant/helpers/service_info/mqtt.py index b683745e1c0..6ffc981ced1 100644 --- a/homeassistant/helpers/service_info/mqtt.py +++ b/homeassistant/helpers/service_info/mqtt.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from homeassistant.data_entry_flow import BaseServiceInfo -ReceivePayloadType = str | bytes +type ReceivePayloadType = str | bytes @dataclass(slots=True) diff --git a/homeassistant/helpers/significant_change.py b/homeassistant/helpers/significant_change.py index 3b13c359faa..893ca7a3586 100644 --- a/homeassistant/helpers/significant_change.py +++ b/homeassistant/helpers/significant_change.py @@ -41,7 +41,7 @@ from .integration_platform import async_process_integration_platforms PLATFORM = "significant_change" DATA_FUNCTIONS: HassKey[dict[str, CheckTypeFunc]] = HassKey("significant_change") -CheckTypeFunc = Callable[ +type CheckTypeFunc = Callable[ [ HomeAssistant, str, @@ -52,7 +52,7 @@ CheckTypeFunc = Callable[ bool | None, ] -ExtraCheckTypeFunc = Callable[ +type ExtraCheckTypeFunc = Callable[ [ HomeAssistant, str, diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py index 82f78cd10e2..8f5e2418b14 100644 --- a/homeassistant/helpers/sun.py +++ b/homeassistant/helpers/sun.py @@ -22,7 +22,7 @@ DATA_LOCATION_CACHE: HassKey[ ELEVATION_AGNOSTIC_EVENTS = ("noon", "midnight") -_AstralSunEventCallable = Callable[..., datetime.datetime] +type _AstralSunEventCallable = Callable[..., datetime.datetime] @callback diff --git a/homeassistant/helpers/typing.py b/homeassistant/helpers/typing.py index a10c59b6a48..13c54862b8d 100644 --- a/homeassistant/helpers/typing.py +++ b/homeassistant/helpers/typing.py @@ -14,16 +14,16 @@ from .deprecation import ( dir_with_deprecated_constants, ) -GPSType = tuple[float, float] -ConfigType = dict[str, Any] -DiscoveryInfoType = dict[str, Any] -ServiceDataType = dict[str, Any] -StateType = str | int | float | None -TemplateVarsType = Mapping[str, Any] | None -NoEventData = Mapping[str, Never] +type GPSType = tuple[float, float] +type ConfigType = dict[str, Any] +type DiscoveryInfoType = dict[str, Any] +type ServiceDataType = dict[str, Any] +type StateType = str | int | float | None +type TemplateVarsType = Mapping[str, Any] | None +type NoEventData = Mapping[str, Never] # Custom type for recorder Queries -QueryType = Any +type QueryType = Any class UndefinedType(Enum): diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index 07a8f446ecb..ff9b7cb3601 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -215,7 +215,7 @@ class SafeLineLoader(PythonSafeLoader): ) -LoaderType = FastSafeLoader | PythonSafeLoader +type LoaderType = FastSafeLoader | PythonSafeLoader def load_yaml( diff --git a/tests/typing.py b/tests/typing.py index 18824163fd2..dc0c35d5dba 100644 --- a/tests/typing.py +++ b/tests/typing.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Callable, Coroutine -from typing import TYPE_CHECKING, Any, TypeAlias +from typing import TYPE_CHECKING, Any from unittest.mock import MagicMock from aiohttp import ClientWebSocketResponse @@ -30,6 +30,6 @@ MqttMockHAClient = MagicMock """MagicMock for `homeassistant.components.mqtt.MQTT`.""" MqttMockHAClientGenerator = Callable[..., Coroutine[Any, Any, MqttMockHAClient]] """MagicMock generator for `homeassistant.components.mqtt.MQTT`.""" -RecorderInstanceGenerator: TypeAlias = Callable[..., Coroutine[Any, Any, "Recorder"]] +type RecorderInstanceGenerator = Callable[..., Coroutine[Any, Any, "Recorder"]] """Instance generator for `homeassistant.components.recorder.Recorder`.""" WebSocketGenerator = Callable[..., Coroutine[Any, Any, MockHAClientWebSocket]]