diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index 2a9525181f65eb..2d0c98cdd14c4a 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -34,9 +34,9 @@ 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 72edb195a81351..d2010dc2c9dc4f 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 3411ae860fbb84..a4bef86241bab8 100644 --- a/homeassistant/auth/permissions/types.py +++ b/homeassistant/auth/permissions/types.py @@ -4,17 +4,17 @@ # 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 @@ ) # 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 db85e18f60ca0c..e1d1f660d7549e 100644 --- a/homeassistant/auth/permissions/util.py +++ b/homeassistant/auth/permissions/util.py @@ -10,8 +10,8 @@ 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 32d1934e093d28..564633073fc895 100644 --- a/homeassistant/auth/providers/trusted_networks.py +++ b/homeassistant/auth/providers/trusted_networks.py @@ -28,8 +28,8 @@ 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 71b3d9f15927a4..2b4b306b68e8d1 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 fadc1c5e553c87..026935474f2acd 100644 --- a/homeassistant/components/auth/__init__.py +++ b/homeassistant/components/auth/__init__.py @@ -164,8 +164,8 @@ 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 a97056e1f4bc7e..deab00430976cb 100644 --- a/homeassistant/components/bluetooth/models.py +++ b/homeassistant/components/bluetooth/models.py @@ -8,5 +8,5 @@ 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 ad86ab1957d7c5..523a634704c746 100644 --- a/homeassistant/components/calendar/trigger.py +++ b/homeassistant/components/calendar/trigger.py @@ -88,8 +88,8 @@ def __str__(self) -> str: 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 861b184975b73a..f8e8e6bf22bef8 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 905214e0d1d7f1..9aab4698bf3a5c 100644 --- a/homeassistant/components/canary/sensor.py +++ b/homeassistant/components/canary/sensor.py @@ -21,7 +21,9 @@ 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 b2cf9a136ccc15..d1ddcb6cd4b8e6 100644 --- a/homeassistant/components/configurator/__init__.py +++ b/homeassistant/components/configurator/__init__.py @@ -49,7 +49,7 @@ 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 6d95d18214e53b..b79c9e56a9523a 100644 --- a/homeassistant/components/device_automation/__init__.py +++ b/homeassistant/components/device_automation/__init__.py @@ -9,7 +9,7 @@ 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 @@ 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 837bfc456d80e4..7d9efc4096c598 100644 --- a/homeassistant/components/dlna_dmr/config_flow.py +++ b/homeassistant/components/dlna_dmr/config_flow.py @@ -40,7 +40,7 @@ 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 d0da07da37ccac..9c5a9fbacd1647 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 d52a15a60c8346..96b122da8391d2 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 38cd87a22f5eae..4135c49bf8b5a9 100644 --- a/homeassistant/components/energy/websocket_api.py +++ b/homeassistant/components/energy/websocket_api.py @@ -33,12 +33,12 @@ 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 9573627e130193..641a0a74fa7927 100644 --- a/homeassistant/components/firmata/board.py +++ b/homeassistant/components/firmata/board.py @@ -30,7 +30,7 @@ _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 8702339ef0387c..083085270e09c6 100644 --- a/homeassistant/components/fronius/const.py +++ b/homeassistant/components/fronius/const.py @@ -8,7 +8,7 @@ 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 d9ab6b169602a0..04464fe25672fc 100644 --- a/homeassistant/components/greeneye_monitor/sensor.py +++ b/homeassistant/components/greeneye_monitor/sensor.py @@ -115,7 +115,7 @@ def on_new_monitor(monitor: greeneye.monitor.Monitor) -> None: 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 e923df82843b5b..ec42c47f9fff78 100644 --- a/homeassistant/components/harmony/subscriber.py +++ b/homeassistant/components/harmony/subscriber.py @@ -10,8 +10,8 @@ _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 78190634affc7d..2479dc3c181e7f 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -57,9 +57,9 @@ _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 2f94f5bac9241a..ac436ce27a491f 100644 --- a/homeassistant/components/homekit_controller/utils.py +++ b/homeassistant/components/homekit_controller/utils.py @@ -12,7 +12,7 @@ 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 1f9905f4e9c380..0e35208dcce054 100644 --- a/homeassistant/components/huawei_lte/device_tracker.py +++ b/homeassistant/components/huawei_lte/device_tracker.py @@ -34,7 +34,7 @@ _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 bc650569a6302d..650a9384e35237 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 ..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 8aeac4d8180b8b..a7861ebd7b4399 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 @@ 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 e46ca5619649f4..6e90d3ca775f3e 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 ..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 5ade839aacd571..e653ccfa9304a9 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 9c0d5e1125aad3..67e009cacfc2e0 100644 --- a/homeassistant/components/knx/const.py +++ b/homeassistant/components/knx/const.py @@ -86,8 +86,8 @@ # 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 3b1bc29c7cdc66..9fbad46dd4b755 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 b0b1a2f1c040b5..d46628fc6da117 100644 --- a/homeassistant/components/lcn/helpers.py +++ b/homeassistant/components/lcn/helpers.py @@ -6,7 +6,7 @@ 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 @@ ) # 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 18e503523ae04d..c10219d8a335fc 100644 --- a/homeassistant/components/matter/models.py +++ b/homeassistant/components/matter/models.py @@ -13,7 +13,7 @@ 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 4c435adda7dd3f..6c70b39c964649 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -467,7 +467,7 @@ def forward_messages(mqttmsg: ReceiveMessage) -> None: 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 02998f5d6dd6a2..57aa8a11686dd1 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -99,9 +99,9 @@ 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 bba543893c9709..eda26f2559efcf 100644 --- a/homeassistant/components/mqtt/models.py +++ b/homeassistant/components/mqtt/models.py @@ -44,7 +44,7 @@ class PayloadSentinel(StrEnum): 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 3885a2d7a0ef05..a65b46616d3490 100644 --- a/homeassistant/components/mysensors/const.py +++ b/homeassistant/components/mysensors/const.py @@ -19,7 +19,7 @@ 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 975ddae346ae3b..ed8cb2d2002629 100644 --- a/homeassistant/components/plugwise/const.py +++ b/homeassistant/components/plugwise/const.py @@ -37,19 +37,19 @@ "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 69db399a454cc1..3e7bafed748d48 100644 --- a/homeassistant/components/private_ble_device/coordinator.py +++ b/homeassistant/components/private_ble_device/coordinator.py @@ -17,8 +17,8 @@ _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 1ac37f10eb9e40..09affe4369b7ed 100644 --- a/homeassistant/components/roku/browse_media.py +++ b/homeassistant/components/roku/browse_media.py @@ -40,7 +40,7 @@ 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 31e8468240f4fc..a40b5415fe3155 100644 --- a/homeassistant/components/screenlogic/const.py +++ b/homeassistant/components/screenlogic/const.py @@ -15,7 +15,7 @@ ) 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 d40b485bf894be..288bf005a5c774 100644 --- a/homeassistant/components/senz/__init__.py +++ b/homeassistant/components/senz/__init__.py @@ -30,7 +30,7 @@ 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 5651a3072b9e7d..712cc59903deeb 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 eeadd7db232e6a..498607c5465267 100644 --- a/homeassistant/components/sonos/media_browser.py +++ b/homeassistant/components/sonos/media_browser.py @@ -43,7 +43,7 @@ _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 f9e9fc8bee0ee2..272218cc01ec98 100644 --- a/homeassistant/components/sonos/number.py +++ b/homeassistant/components/sonos/number.py @@ -28,7 +28,7 @@ "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 27d96d6ff094eb..17c351793269ef 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 7d3980bcff9641..0ebd04f7e5a6c9 100644 --- a/homeassistant/components/switchbot_cloud/coordinator.py +++ b/homeassistant/components/switchbot_cloud/coordinator.py @@ -13,7 +13,7 @@ _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 369ca283495287..0749f87a67fde8 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -19,7 +19,7 @@ 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 5d70330dbdfa06..92fcbcc7fc4936 100644 --- a/homeassistant/components/tasmota/discovery.py +++ b/homeassistant/components/tasmota/discovery.py @@ -45,7 +45,7 @@ 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 c35f92fd27ffc9..8e44c7e57d32c3 100644 --- a/homeassistant/components/tod/binary_sensor.py +++ b/homeassistant/components/tod/binary_sensor.py @@ -36,7 +36,7 @@ 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 3d44b1ecedeed2..95ce42469f151f 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 6193f06ff4f8ce..79830e0b63f607 100644 --- a/homeassistant/components/trace/__init__.py +++ b/homeassistant/components/trace/__init__.py @@ -40,7 +40,7 @@ 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 99015512498e72..ab22a44cab6407 100644 --- a/homeassistant/components/tts/const.py +++ b/homeassistant/components/tts/const.py @@ -18,4 +18,4 @@ 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 6c5a1472015306..b64a08749d57df 100644 --- a/homeassistant/components/unifiprotect/data.py +++ b/homeassistant/components/unifiprotect/data.py @@ -43,7 +43,7 @@ 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 bd2eb9ff59cba7..ef70df4a1232c2 100644 --- a/homeassistant/components/websocket_api/connection.py +++ b/homeassistant/components/websocket_api/connection.py @@ -26,8 +26,8 @@ "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 25d3ff8dcb3475..3a81508addc557 100644 --- a/homeassistant/components/websocket_api/const.py +++ b/homeassistant/components/websocket_api/const.py @@ -11,11 +11,11 @@ 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 822bf65fdc4b91..3ef7ac92f9887e 100644 --- a/homeassistant/components/wemo/__init__.py +++ b/homeassistant/components/wemo/__init__.py @@ -44,8 +44,8 @@ _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 3e8d87d630001f..9bedd12f54b532 100644 --- a/homeassistant/components/wemo/coordinator.py +++ b/homeassistant/components/wemo/coordinator.py @@ -37,9 +37,9 @@ _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 74110d390eda93..2359fe0a1c3869 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -245,7 +245,7 @@ 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 009364ba9d2e70..8b8826e264848f 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -96,7 +96,7 @@ 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 661515758de9f5..14dcc9d4755dc5 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 8c08a0198b0968..9be67cbfab7cf7 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -141,7 +141,7 @@ _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 @@ # 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 5b22b6d8051083..6498859e2ab6af 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 6e833e338db0f8..da6d3d65b54cee 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 @@ class CollectionChangeSet: 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 e76244240d1110..3959a2147bd000 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -115,7 +115,7 @@ def async_condition_from_config( """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 a0bfc751a122e3..51896ac2be977c 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 81454db57a7fc6..2964c55af74098 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 0a2a8a9346186e..c54af93d3208bf 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -1262,7 +1262,7 @@ def _refresh( 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 6980fdc98c0859..9bf8a2a5d2611d 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 a464056fc075fc..bbe4e26f4e548d 100644 --- a/homeassistant/helpers/http.py +++ b/homeassistant/helpers/http.py @@ -30,7 +30,7 @@ _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 8b8ea8051536c8..3a616b5e29ca4f 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -35,7 +35,7 @@ ) _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 d4150f0a3bbc1a..64e884e142877c 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 94e7f3325fbf12..7af29fb43276d1 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 b683745e1c0685..6ffc981ced104e 100644 --- a/homeassistant/helpers/service_info/mqtt.py +++ b/homeassistant/helpers/service_info/mqtt.py @@ -4,7 +4,7 @@ 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 3b13c359faad28..893ca7a3586bf2 100644 --- a/homeassistant/helpers/significant_change.py +++ b/homeassistant/helpers/significant_change.py @@ -41,7 +41,7 @@ async def async_check_significant_change( PLATFORM = "significant_change" DATA_FUNCTIONS: HassKey[dict[str, CheckTypeFunc]] = HassKey("significant_change") -CheckTypeFunc = Callable[ +type CheckTypeFunc = Callable[ [ HomeAssistant, str, @@ -52,7 +52,7 @@ async def async_check_significant_change( bool | None, ] -ExtraCheckTypeFunc = Callable[ +type ExtraCheckTypeFunc = Callable[ [ HomeAssistant, str, diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py index 82f78cd10e25d6..8f5e2418b14e37 100644 --- a/homeassistant/helpers/sun.py +++ b/homeassistant/helpers/sun.py @@ -22,7 +22,7 @@ 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 a10c59b6a484a0..13c54862b8ddf5 100644 --- a/homeassistant/helpers/typing.py +++ b/homeassistant/helpers/typing.py @@ -14,16 +14,16 @@ 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 07a8f446ecb54a..ff9b7cb3601932 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -215,7 +215,7 @@ def __report_deprecated() -> None: ) -LoaderType = FastSafeLoader | PythonSafeLoader +type LoaderType = FastSafeLoader | PythonSafeLoader def load_yaml( diff --git a/tests/typing.py b/tests/typing.py index 18824163fd2e4a..dc0c35d5dba171 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 @@ class MockHAClientWebSocket(ClientWebSocketResponse): """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]]