Update Optional typing (1) [Py310] (#86417)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
da35097803
commit
6397138589
35 changed files with 95 additions and 113 deletions
|
@ -5,7 +5,7 @@ import asyncio
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ EVENT_USER_UPDATED = "user_updated"
|
||||||
EVENT_USER_REMOVED = "user_removed"
|
EVENT_USER_REMOVED = "user_removed"
|
||||||
|
|
||||||
_MfaModuleDict = dict[str, MultiFactorAuthModule]
|
_MfaModuleDict = dict[str, MultiFactorAuthModule]
|
||||||
_ProviderKey = tuple[str, Optional[str]]
|
_ProviderKey = tuple[str, str | None]
|
||||||
_ProviderDict = dict[_ProviderKey, AuthProvider]
|
_ProviderDict = dict[_ProviderKey, AuthProvider]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from .const import SUBCAT_ALL
|
from .const import SUBCAT_ALL
|
||||||
from .models import PermissionLookup
|
from .models import PermissionLookup
|
||||||
from .types import CategoryType, SubCategoryDict, ValueType
|
from .types import CategoryType, SubCategoryDict, ValueType
|
||||||
|
|
||||||
LookupFunc = Callable[[PermissionLookup, SubCategoryDict, str], Optional[ValueType]]
|
LookupFunc = Callable[[PermissionLookup, SubCategoryDict, str], ValueType | None]
|
||||||
SubCatLookupType = dict[str, LookupFunc]
|
SubCatLookupType = dict[str, LookupFunc]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ from __future__ import annotations
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
@ -159,7 +159,7 @@ from . import indieauth, login_flow, mfa_setup_flow
|
||||||
DOMAIN = "auth"
|
DOMAIN = "auth"
|
||||||
|
|
||||||
StoreResultType = Callable[[str, Credentials], str]
|
StoreResultType = Callable[[str, Credentials], str]
|
||||||
RetrieveResultType = Callable[[str, str], Optional[Credentials]]
|
RetrieveResultType = Callable[[str, str], Credentials | None]
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from aiobafi6 import Device
|
from aiobafi6 import Device
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ OCCUPANCY_SENSORS = (
|
||||||
key="occupancy",
|
key="occupancy",
|
||||||
name="Occupancy",
|
name="Occupancy",
|
||||||
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.fan_occupancy_detected),
|
value_fn=lambda device: cast(bool | None, device.fan_occupancy_detected),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from aiobafi6 import Device
|
from aiobafi6 import Device
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||||
native_min_value=0,
|
native_min_value=0,
|
||||||
native_max_value=SPEED_RANGE[1] - 1,
|
native_max_value=SPEED_RANGE[1] - 1,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[int], device.comfort_min_speed),
|
value_fn=lambda device: cast(int | None, device.comfort_min_speed),
|
||||||
mode=NumberMode.BOX,
|
mode=NumberMode.BOX,
|
||||||
),
|
),
|
||||||
BAFNumberDescription(
|
BAFNumberDescription(
|
||||||
|
@ -52,7 +52,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||||
native_min_value=1,
|
native_min_value=1,
|
||||||
native_max_value=SPEED_RANGE[1],
|
native_max_value=SPEED_RANGE[1],
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[int], device.comfort_max_speed),
|
value_fn=lambda device: cast(int | None, device.comfort_max_speed),
|
||||||
mode=NumberMode.BOX,
|
mode=NumberMode.BOX,
|
||||||
),
|
),
|
||||||
BAFNumberDescription(
|
BAFNumberDescription(
|
||||||
|
@ -61,7 +61,7 @@ AUTO_COMFORT_NUMBER_DESCRIPTIONS = (
|
||||||
native_min_value=SPEED_RANGE[0],
|
native_min_value=SPEED_RANGE[0],
|
||||||
native_max_value=SPEED_RANGE[1],
|
native_max_value=SPEED_RANGE[1],
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[int], device.comfort_heat_assist_speed),
|
value_fn=lambda device: cast(int | None, device.comfort_heat_assist_speed),
|
||||||
mode=NumberMode.BOX,
|
mode=NumberMode.BOX,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -74,7 +74,7 @@ FAN_NUMBER_DESCRIPTIONS = (
|
||||||
native_max_value=HALF_DAY_SECS,
|
native_max_value=HALF_DAY_SECS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
value_fn=lambda device: cast(Optional[int], device.return_to_auto_timeout),
|
value_fn=lambda device: cast(int | None, device.return_to_auto_timeout),
|
||||||
mode=NumberMode.SLIDER,
|
mode=NumberMode.SLIDER,
|
||||||
),
|
),
|
||||||
BAFNumberDescription(
|
BAFNumberDescription(
|
||||||
|
@ -84,7 +84,7 @@ FAN_NUMBER_DESCRIPTIONS = (
|
||||||
native_max_value=ONE_DAY_SECS,
|
native_max_value=ONE_DAY_SECS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
value_fn=lambda device: cast(Optional[int], device.motion_sense_timeout),
|
value_fn=lambda device: cast(int | None, device.motion_sense_timeout),
|
||||||
mode=NumberMode.SLIDER,
|
mode=NumberMode.SLIDER,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -97,9 +97,7 @@ LIGHT_NUMBER_DESCRIPTIONS = (
|
||||||
native_max_value=HALF_DAY_SECS,
|
native_max_value=HALF_DAY_SECS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
value_fn=lambda device: cast(
|
value_fn=lambda device: cast(int | None, device.light_return_to_auto_timeout),
|
||||||
Optional[int], device.light_return_to_auto_timeout
|
|
||||||
),
|
|
||||||
mode=NumberMode.SLIDER,
|
mode=NumberMode.SLIDER,
|
||||||
),
|
),
|
||||||
BAFNumberDescription(
|
BAFNumberDescription(
|
||||||
|
@ -109,7 +107,7 @@ LIGHT_NUMBER_DESCRIPTIONS = (
|
||||||
native_max_value=ONE_DAY_SECS,
|
native_max_value=ONE_DAY_SECS,
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
value_fn=lambda device: cast(Optional[int], device.light_auto_motion_timeout),
|
value_fn=lambda device: cast(int | None, device.light_auto_motion_timeout),
|
||||||
mode=NumberMode.SLIDER,
|
mode=NumberMode.SLIDER,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from aiobafi6 import Device
|
from aiobafi6 import Device
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ AUTO_COMFORT_SENSORS = (
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda device: cast(Optional[float], device.temperature),
|
value_fn=lambda device: cast(float | None, device.temperature),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ DEFINED_ONLY_SENSORS = (
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda device: cast(Optional[float], device.humidity),
|
value_fn=lambda device: cast(float | None, device.humidity),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ FAN_SENSORS = (
|
||||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: cast(Optional[int], device.current_rpm),
|
value_fn=lambda device: cast(int | None, device.current_rpm),
|
||||||
),
|
),
|
||||||
BAFSensorDescription(
|
BAFSensorDescription(
|
||||||
key="target_rpm",
|
key="target_rpm",
|
||||||
|
@ -76,21 +76,21 @@ FAN_SENSORS = (
|
||||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: cast(Optional[int], device.target_rpm),
|
value_fn=lambda device: cast(int | None, device.target_rpm),
|
||||||
),
|
),
|
||||||
BAFSensorDescription(
|
BAFSensorDescription(
|
||||||
key="wifi_ssid",
|
key="wifi_ssid",
|
||||||
name="WiFi SSID",
|
name="WiFi SSID",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: cast(Optional[int], device.wifi_ssid),
|
value_fn=lambda device: cast(int | None, device.wifi_ssid),
|
||||||
),
|
),
|
||||||
BAFSensorDescription(
|
BAFSensorDescription(
|
||||||
key="ip_address",
|
key="ip_address",
|
||||||
name="IP Address",
|
name="IP Address",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: cast(Optional[str], device.ip_address),
|
value_fn=lambda device: cast(str | None, device.ip_address),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from aiobafi6 import Device
|
from aiobafi6 import Device
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ BASE_SWITCHES = [
|
||||||
key="legacy_ir_remote_enable",
|
key="legacy_ir_remote_enable",
|
||||||
name="Legacy IR Remote",
|
name="Legacy IR Remote",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.legacy_ir_remote_enable),
|
value_fn=lambda device: cast(bool | None, device.legacy_ir_remote_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="led_indicators_enable",
|
key="led_indicators_enable",
|
||||||
name="Led Indicators",
|
name="Led Indicators",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.led_indicators_enable),
|
value_fn=lambda device: cast(bool | None, device.led_indicators_enable),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ AUTO_COMFORT_SWITCHES = [
|
||||||
key="comfort_heat_assist_enable",
|
key="comfort_heat_assist_enable",
|
||||||
name="Auto Comfort Heat Assist",
|
name="Auto Comfort Heat Assist",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.comfort_heat_assist_enable),
|
value_fn=lambda device: cast(bool | None, device.comfort_heat_assist_enable),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -62,31 +62,31 @@ FAN_SWITCHES = [
|
||||||
key="fan_beep_enable",
|
key="fan_beep_enable",
|
||||||
name="Beep",
|
name="Beep",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.fan_beep_enable),
|
value_fn=lambda device: cast(bool | None, device.fan_beep_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="eco_enable",
|
key="eco_enable",
|
||||||
name="Eco Mode",
|
name="Eco Mode",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.eco_enable),
|
value_fn=lambda device: cast(bool | None, device.eco_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="motion_sense_enable",
|
key="motion_sense_enable",
|
||||||
name="Motion Sense",
|
name="Motion Sense",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.motion_sense_enable),
|
value_fn=lambda device: cast(bool | None, device.motion_sense_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="return_to_auto_enable",
|
key="return_to_auto_enable",
|
||||||
name="Return to Auto",
|
name="Return to Auto",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.return_to_auto_enable),
|
value_fn=lambda device: cast(bool | None, device.return_to_auto_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="whoosh_enable",
|
key="whoosh_enable",
|
||||||
name="Whoosh",
|
name="Whoosh",
|
||||||
# Not a configuration switch
|
# Not a configuration switch
|
||||||
value_fn=lambda device: cast(Optional[bool], device.whoosh_enable),
|
value_fn=lambda device: cast(bool | None, device.whoosh_enable),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -96,15 +96,13 @@ LIGHT_SWITCHES = [
|
||||||
key="light_dim_to_warm_enable",
|
key="light_dim_to_warm_enable",
|
||||||
name="Dim to Warm",
|
name="Dim to Warm",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(Optional[bool], device.light_dim_to_warm_enable),
|
value_fn=lambda device: cast(bool | None, device.light_dim_to_warm_enable),
|
||||||
),
|
),
|
||||||
BAFSwitchDescription(
|
BAFSwitchDescription(
|
||||||
key="light_return_to_auto_enable",
|
key="light_return_to_auto_enable",
|
||||||
name="Light Return to Auto",
|
name="Light Return to Auto",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
value_fn=lambda device: cast(
|
value_fn=lambda device: cast(bool | None, device.light_return_to_auto_enable),
|
||||||
Optional[bool], device.light_return_to_auto_enable
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Brunt Blind Engine covers."""
|
"""Support for Brunt Blind Engine covers."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientResponseError
|
from aiohttp.client_exceptions import ClientResponseError
|
||||||
from brunt import BruntClientAsync, Thing
|
from brunt import BruntClientAsync, Thing
|
||||||
|
@ -53,7 +53,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class BruntDevice(
|
class BruntDevice(
|
||||||
CoordinatorEntity[DataUpdateCoordinator[dict[Optional[str], Thing]]], CoverEntity
|
CoordinatorEntity[DataUpdateCoordinator[dict[str | None, Thing]]], CoverEntity
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Representation of a Brunt cover device.
|
Representation of a Brunt cover device.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Support for BTHome binary sensors."""
|
"""Support for BTHome binary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from bthome_ble import (
|
from bthome_ble import (
|
||||||
BinarySensorDeviceClass as BTHomeBinarySensorDeviceClass,
|
BinarySensorDeviceClass as BTHomeBinarySensorDeviceClass,
|
||||||
SensorUpdate,
|
SensorUpdate,
|
||||||
|
@ -188,7 +186,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class BTHomeBluetoothBinarySensorEntity(
|
class BTHomeBluetoothBinarySensorEntity(
|
||||||
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[Optional[bool]]],
|
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[bool | None]],
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
):
|
):
|
||||||
"""Representation of a BTHome binary sensor."""
|
"""Representation of a BTHome binary sensor."""
|
||||||
|
|
|
@ -12,7 +12,7 @@ from functools import partial
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from random import SystemRandom
|
from random import SystemRandom
|
||||||
from typing import Any, Final, Optional, cast, final
|
from typing import Any, Final, cast, final
|
||||||
|
|
||||||
from aiohttp import hdrs, web
|
from aiohttp import hdrs, web
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
@ -294,7 +294,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
|
# 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 output is the SDP answer, or None if the source or offer is not eligible.
|
||||||
# The Callable may throw HomeAssistantError on failure.
|
# The Callable may throw HomeAssistantError on failure.
|
||||||
RtspToWebRtcProviderType = Callable[[str, str, str], Awaitable[Optional[str]]]
|
RtspToWebRtcProviderType = Callable[[str, str, str], Awaitable[str | None]]
|
||||||
|
|
||||||
|
|
||||||
def async_register_rtsp_to_web_rtc_provider(
|
def async_register_rtsp_to_web_rtc_provider(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Canary sensors."""
|
"""Support for Canary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Final, Optional
|
from typing import Final
|
||||||
|
|
||||||
from canary.model import Device, Location, SensorType
|
from canary.model import Device, Location, SensorType
|
||||||
|
|
||||||
|
@ -20,9 +20,7 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from .const import DATA_COORDINATOR, DOMAIN, MANUFACTURER
|
from .const import DATA_COORDINATOR, DOMAIN, MANUFACTURER
|
||||||
from .coordinator import CanaryDataUpdateCoordinator
|
from .coordinator import CanaryDataUpdateCoordinator
|
||||||
|
|
||||||
SensorTypeItem = tuple[
|
SensorTypeItem = tuple[str, str | None, str | None, SensorDeviceClass | None, list[str]]
|
||||||
str, Optional[str], Optional[str], Optional[SensorDeviceClass], list[str]
|
|
||||||
]
|
|
||||||
|
|
||||||
SENSOR_VALUE_PRECISION: Final = 2
|
SENSOR_VALUE_PRECISION: Final = 2
|
||||||
ATTR_AIR_QUALITY: Final = "air_quality"
|
ATTR_AIR_QUALITY: Final = "air_quality"
|
||||||
|
|
|
@ -5,7 +5,6 @@ import asyncio
|
||||||
import configparser
|
import configparser
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
@ -33,7 +32,7 @@ class ChromecastInfo:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cast_info: CastInfo = attr.ib()
|
cast_info: CastInfo = attr.ib()
|
||||||
is_dynamic_group = attr.ib(type=Optional[bool], default=None)
|
is_dynamic_group = attr.ib(type=bool | None, default=None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def friendly_name(self) -> str:
|
def friendly_name(self) -> str:
|
||||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -60,7 +59,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
|
|
||||||
class CertExpiryDataUpdateCoordinator(DataUpdateCoordinator[Optional[datetime]]):
|
class CertExpiryDataUpdateCoordinator(DataUpdateCoordinator[datetime | None]):
|
||||||
"""Class to manage fetching Cert Expiry data from single endpoint."""
|
"""Class to manage fetching Cert Expiry data from single endpoint."""
|
||||||
|
|
||||||
def __init__(self, hass, host, port):
|
def __init__(self, hass, host, port):
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
from homeassistant.components.sensor import SensorEntity, SensorStateClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -90,7 +89,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class KrakenSensor(
|
class KrakenSensor(
|
||||||
CoordinatorEntity[DataUpdateCoordinator[Optional[KrakenResponse]]], SensorEntity
|
CoordinatorEntity[DataUpdateCoordinator[KrakenResponse | None]], SensorEntity
|
||||||
):
|
):
|
||||||
"""Define a Kraken sensor."""
|
"""Define a Kraken sensor."""
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class DashboardsCollection(collection.StorageCollection):
|
||||||
async def _async_load_data(self) -> dict | None:
|
async def _async_load_data(self) -> dict | None:
|
||||||
"""Load the data."""
|
"""Load the data."""
|
||||||
if (data := await self.store.async_load()) is None:
|
if (data := await self.store.async_load()) is None:
|
||||||
return cast(Optional[dict], data)
|
return cast(dict | None, data)
|
||||||
|
|
||||||
updated = False
|
updated = False
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ class DashboardsCollection(collection.StorageCollection):
|
||||||
if updated:
|
if updated:
|
||||||
await self.store.async_save(data)
|
await self.store.async_save(data)
|
||||||
|
|
||||||
return cast(Optional[dict], data)
|
return cast(dict | None, data)
|
||||||
|
|
||||||
async def _process_create_data(self, data: dict) -> dict:
|
async def _process_create_data(self, data: dict) -> dict:
|
||||||
"""Validate the config is valid."""
|
"""Validate the config is valid."""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -71,7 +71,7 @@ class ResourceStorageCollection(collection.StorageCollection):
|
||||||
async def _async_load_data(self) -> dict | None:
|
async def _async_load_data(self) -> dict | None:
|
||||||
"""Load the data."""
|
"""Load the data."""
|
||||||
if (data := await self.store.async_load()) is not None:
|
if (data := await self.store.async_load()) is not None:
|
||||||
return cast(Optional[dict], data)
|
return cast(dict | None, data)
|
||||||
|
|
||||||
# Import it from config.
|
# Import it from config.
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import PurePath
|
from pathlib import PurePath
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from motioneye_client.const import KEY_MEDIA_LIST, KEY_MIME_TYPE, KEY_PATH
|
from motioneye_client.const import KEY_MEDIA_LIST, KEY_MIME_TYPE, KEY_PATH
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class MotionEyeMediaSource(MediaSource):
|
||||||
base = [None] * 4
|
base = [None] * 4
|
||||||
data = identifier.split("#", 3)
|
data = identifier.split("#", 3)
|
||||||
return cast(
|
return cast(
|
||||||
tuple[Optional[str], Optional[str], Optional[str], Optional[str]],
|
tuple[str | None, str | None, str | None, str | None],
|
||||||
tuple(data + base)[:4], # type: ignore[operator]
|
tuple(data + base)[:4], # type: ignore[operator]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from homeassistant.components.remote import (
|
from homeassistant.components.remote import (
|
||||||
ATTR_COMMAND,
|
ATTR_COMMAND,
|
||||||
|
@ -59,7 +59,7 @@ class MySensorsRemote(MySensorsEntity, RemoteEntity):
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return True if remote is on."""
|
"""Return True if remote is on."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
value = cast(Optional[str], self._child.values.get(set_req.V_LIGHT))
|
value = cast(str | None, self._child.values.get(set_req.V_LIGHT))
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
return value == "1"
|
return value == "1"
|
||||||
|
@ -120,5 +120,5 @@ class MySensorsRemote(MySensorsEntity, RemoteEntity):
|
||||||
"""Update the controller with the latest value from a device."""
|
"""Update the controller with the latest value from a device."""
|
||||||
super()._async_update()
|
super()._async_update()
|
||||||
self._current_command = cast(
|
self._current_command = cast(
|
||||||
Optional[str], self._child.values.get(self.value_type)
|
str | None, self._child.values.get(self.value_type)
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import Any, Optional, Protocol, cast
|
from typing import Any, Protocol, cast
|
||||||
|
|
||||||
from homeassistant.const import CONF_DESCRIPTION, CONF_NAME
|
from homeassistant.const import CONF_DESCRIPTION, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
|
@ -71,7 +71,7 @@ def async_setup_legacy(
|
||||||
p_config = {}
|
p_config = {}
|
||||||
|
|
||||||
platform = cast(
|
platform = cast(
|
||||||
Optional[LegacyNotifyPlatform],
|
LegacyNotifyPlatform | None,
|
||||||
await async_prepare_setup_platform(hass, config, DOMAIN, integration_name),
|
await async_prepare_setup_platform(hass, config, DOMAIN, integration_name),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Support for Qingping binary sensors."""
|
"""Support for Qingping binary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from qingping_ble import (
|
from qingping_ble import (
|
||||||
BinarySensorDeviceClass as QingpingBinarySensorDeviceClass,
|
BinarySensorDeviceClass as QingpingBinarySensorDeviceClass,
|
||||||
SensorUpdate,
|
SensorUpdate,
|
||||||
|
@ -93,7 +91,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class QingpingBluetoothSensorEntity(
|
class QingpingBluetoothSensorEntity(
|
||||||
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[Optional[bool]]],
|
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[bool | None]],
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
):
|
):
|
||||||
"""Representation of a Qingping binary sensor."""
|
"""Representation of a Qingping binary sensor."""
|
||||||
|
|
|
@ -5,7 +5,7 @@ import asyncio
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional, TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
from renault_api.kamereon.exceptions import (
|
from renault_api.kamereon.exceptions import (
|
||||||
AccessDeniedException,
|
AccessDeniedException,
|
||||||
|
@ -17,7 +17,7 @@ from renault_api.kamereon.models import KamereonVehicleDataAttributes
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
T = TypeVar("T", bound=Optional[KamereonVehicleDataAttributes])
|
T = TypeVar("T", bound=KamereonVehicleDataAttributes | None)
|
||||||
|
|
||||||
# We have potentially 7 coordinators per vehicle
|
# We have potentially 7 coordinators per vehicle
|
||||||
_PARALLEL_SEMAPHORE = asyncio.Semaphore(1)
|
_PARALLEL_SEMAPHORE = asyncio.Semaphore(1)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import datetime
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
from typing import TYPE_CHECKING, Any, Optional, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from requests.exceptions import Timeout
|
from requests.exceptions import Timeout
|
||||||
|
@ -483,7 +483,7 @@ class SonosDiscoveryManager:
|
||||||
uid,
|
uid,
|
||||||
discovered_ip,
|
discovered_ip,
|
||||||
"discovery",
|
"discovery",
|
||||||
boot_seqnum=cast(Optional[int], boot_seqnum),
|
boot_seqnum=cast(int | None, boot_seqnum),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import localtime, mktime
|
from time import localtime, mktime
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -79,7 +79,7 @@ class SteamSensor(SteamEntity, SensorEntity):
|
||||||
attrs["game_icon"] = f"{STEAM_ICON_URL}{game_id}/{info}.jpg"
|
attrs["game_icon"] = f"{STEAM_ICON_URL}{game_id}/{info}.jpg"
|
||||||
self._attr_name = str(player["personaname"]) or None
|
self._attr_name = str(player["personaname"]) or None
|
||||||
self._attr_entity_picture = str(player["avatarmedium"]) or None
|
self._attr_entity_picture = str(player["avatarmedium"]) or None
|
||||||
if last_online := cast(Optional[int], player.get("lastlogoff")):
|
if last_online := cast(int | None, player.get("lastlogoff")):
|
||||||
attrs["last_online"] = utc_from_timestamp(mktime(localtime(last_online)))
|
attrs["last_online"] = utc_from_timestamp(mktime(localtime(last_online)))
|
||||||
if level := self.coordinator.data[self.entity_description.key]["level"]:
|
if level := self.coordinator.data[self.entity_description.key]["level"]:
|
||||||
attrs["level"] = level
|
attrs["level"] = level
|
||||||
|
|
|
@ -11,7 +11,7 @@ import mimetypes
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
from typing import TYPE_CHECKING, Any, Optional, TypedDict, cast
|
from typing import TYPE_CHECKING, Any, TypedDict, cast
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import mutagen
|
import mutagen
|
||||||
|
@ -51,7 +51,7 @@ from .media_source import generate_media_source_id, media_source_id_to_kwargs
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
TtsAudioType = tuple[Optional[str], Optional[bytes]]
|
TtsAudioType = tuple[str | None, bytes | None]
|
||||||
|
|
||||||
ATTR_CACHE = "cache"
|
ATTR_CACHE = "cache"
|
||||||
ATTR_LANGUAGE = "language"
|
ATTR_LANGUAGE = "language"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -95,7 +95,7 @@ class WallboxNumber(WallboxEntity, NumberEntity):
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Return the value of the entity."""
|
"""Return the value of the entity."""
|
||||||
return cast(
|
return cast(
|
||||||
Optional[float], self._coordinator.data[CHARGER_MAX_CHARGING_CURRENT_KEY]
|
float | None, self._coordinator.data[CHARGER_MAX_CHARGING_CURRENT_KEY]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_native_value(self, value: float) -> None:
|
async def async_set_native_value(self, value: float) -> None:
|
||||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import pywemo
|
import pywemo
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -43,7 +42,7 @@ WEMO_MODEL_DISPATCH = {
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
HostPortTuple = tuple[str, Optional[int]]
|
HostPortTuple = tuple[str, int | None]
|
||||||
|
|
||||||
|
|
||||||
def coerce_host_port(value: str) -> HostPortTuple:
|
def coerce_host_port(value: str) -> HostPortTuple:
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from whois import Domain
|
from whois import Domain
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class WhoisSensorEntity(
|
class WhoisSensorEntity(
|
||||||
CoordinatorEntity[DataUpdateCoordinator[Optional[Domain]]], SensorEntity
|
CoordinatorEntity[DataUpdateCoordinator[Domain | None]], SensorEntity
|
||||||
):
|
):
|
||||||
"""Implementation of a WHOIS sensor."""
|
"""Implementation of a WHOIS sensor."""
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from pywizlight.bulblibrary import BulbType
|
from pywizlight.bulblibrary import BulbType
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ from homeassistant.helpers.update_coordinator import (
|
||||||
from .models import WizData
|
from .models import WizData
|
||||||
|
|
||||||
|
|
||||||
class WizEntity(CoordinatorEntity[DataUpdateCoordinator[Optional[float]]], Entity):
|
class WizEntity(CoordinatorEntity[DataUpdateCoordinator[float | None]], Entity):
|
||||||
"""Representation of WiZ entity."""
|
"""Representation of WiZ entity."""
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, cast
|
from typing import cast
|
||||||
|
|
||||||
from pywizlight import wizlight
|
from pywizlight import wizlight
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ NUMBERS: tuple[WizNumberEntityDescription, ...] = (
|
||||||
native_step=1,
|
native_step=1,
|
||||||
icon="mdi:speedometer",
|
icon="mdi:speedometer",
|
||||||
name="Effect speed",
|
name="Effect speed",
|
||||||
value_fn=lambda device: cast(Optional[int], device.state.get_speed()),
|
value_fn=lambda device: cast(int | None, device.state.get_speed()),
|
||||||
set_value_fn=_async_set_speed,
|
set_value_fn=_async_set_speed,
|
||||||
required_feature="effect",
|
required_feature="effect",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
@ -66,7 +66,7 @@ NUMBERS: tuple[WizNumberEntityDescription, ...] = (
|
||||||
native_step=1,
|
native_step=1,
|
||||||
icon="mdi:floor-lamp-dual",
|
icon="mdi:floor-lamp-dual",
|
||||||
name="Dual head ratio",
|
name="Dual head ratio",
|
||||||
value_fn=lambda device: cast(Optional[int], device.state.get_ratio()),
|
value_fn=lambda device: cast(int | None, device.state.get_ratio()),
|
||||||
set_value_fn=_async_set_ratio,
|
set_value_fn=_async_set_ratio,
|
||||||
required_feature="dual_head",
|
required_feature="dual_head",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Support for Xiaomi binary sensors."""
|
"""Support for Xiaomi binary sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from xiaomi_ble.parser import (
|
from xiaomi_ble.parser import (
|
||||||
BinarySensorDeviceClass as XiaomiBinarySensorDeviceClass,
|
BinarySensorDeviceClass as XiaomiBinarySensorDeviceClass,
|
||||||
ExtendedBinarySensorDeviceClass,
|
ExtendedBinarySensorDeviceClass,
|
||||||
|
@ -121,7 +119,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class XiaomiBluetoothSensorEntity(
|
class XiaomiBluetoothSensorEntity(
|
||||||
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[Optional[bool]]],
|
PassiveBluetoothProcessorEntity[PassiveBluetoothDataProcessor[bool | None]],
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
):
|
):
|
||||||
"""Representation of a Xiaomi binary sensor."""
|
"""Representation of a Xiaomi binary sensor."""
|
||||||
|
|
|
@ -11,7 +11,7 @@ import functools
|
||||||
import logging
|
import logging
|
||||||
from random import randint
|
from random import randint
|
||||||
from types import MappingProxyType, MethodType
|
from types import MappingProxyType, MethodType
|
||||||
from typing import TYPE_CHECKING, Any, Optional, TypeVar, cast
|
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
from . import data_entry_flow, loader
|
from . import data_entry_flow, loader
|
||||||
|
@ -1437,7 +1437,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
if not self.context:
|
if not self.context:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return cast(Optional[str], self.context.get("unique_id"))
|
return cast(str | None, self.context.get("unique_id"))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
|
|
|
@ -31,10 +31,8 @@ from typing import (
|
||||||
Any,
|
Any,
|
||||||
Generic,
|
Generic,
|
||||||
NamedTuple,
|
NamedTuple,
|
||||||
Optional,
|
|
||||||
ParamSpec,
|
ParamSpec,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
|
||||||
cast,
|
cast,
|
||||||
overload,
|
overload,
|
||||||
)
|
)
|
||||||
|
@ -448,7 +446,7 @@ class HomeAssistant:
|
||||||
# the type used for the cast. For history see:
|
# the type used for the cast. For history see:
|
||||||
# https://github.com/home-assistant/core/pull/71960
|
# https://github.com/home-assistant/core/pull/71960
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
target = cast(Callable[..., Union[Coroutine[Any, Any, _R], _R]], target)
|
target = cast(Callable[..., Coroutine[Any, Any, _R] | _R], target)
|
||||||
return self.async_add_hass_job(HassJob(target), *args)
|
return self.async_add_hass_job(HassJob(target), *args)
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
|
@ -626,7 +624,7 @@ class HomeAssistant:
|
||||||
# the type used for the cast. For history see:
|
# the type used for the cast. For history see:
|
||||||
# https://github.com/home-assistant/core/pull/71960
|
# https://github.com/home-assistant/core/pull/71960
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
target = cast(Callable[..., Union[Coroutine[Any, Any, _R], _R]], target)
|
target = cast(Callable[..., Coroutine[Any, Any, _R] | _R], target)
|
||||||
return self.async_run_hass_job(HassJob(target), *args)
|
return self.async_run_hass_job(HassJob(target), *args)
|
||||||
|
|
||||||
def block_till_done(self) -> None:
|
def block_till_done(self) -> None:
|
||||||
|
@ -2011,13 +2009,13 @@ class Config:
|
||||||
if time_zone is not None:
|
if time_zone is not None:
|
||||||
self.set_time_zone(time_zone)
|
self.set_time_zone(time_zone)
|
||||||
if external_url is not _UNDEF:
|
if external_url is not _UNDEF:
|
||||||
self.external_url = cast(Optional[str], external_url)
|
self.external_url = cast(str | None, external_url)
|
||||||
if internal_url is not _UNDEF:
|
if internal_url is not _UNDEF:
|
||||||
self.internal_url = cast(Optional[str], internal_url)
|
self.internal_url = cast(str | None, internal_url)
|
||||||
if currency is not None:
|
if currency is not None:
|
||||||
self.currency = currency
|
self.currency = currency
|
||||||
if country is not _UNDEF:
|
if country is not _UNDEF:
|
||||||
self.country = cast(Optional[str], country)
|
self.country = cast(str | None, country)
|
||||||
if language is not None:
|
if language is not None:
|
||||||
self.language = language
|
self.language = language
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from collections.abc import Awaitable, Callable, Coroutine, Iterable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from voluptuous.humanize import humanize_error
|
from voluptuous.humanize import humanize_error
|
||||||
|
@ -238,7 +238,7 @@ class StorageCollection(ObservableCollection, ABC):
|
||||||
|
|
||||||
async def _async_load_data(self) -> dict | None:
|
async def _async_load_data(self) -> dict | None:
|
||||||
"""Load the data."""
|
"""Load the data."""
|
||||||
return cast(Optional[dict], await self.store.async_load())
|
return cast(dict | None, await self.store.async_load())
|
||||||
|
|
||||||
async def async_load(self) -> None:
|
async def async_load(self) -> None:
|
||||||
"""Load the storage Manager."""
|
"""Load the storage Manager."""
|
||||||
|
|
|
@ -10,7 +10,7 @@ import functools as ft
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Optional, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from homeassistant.components import zone as zone_cmp
|
from homeassistant.components import zone as zone_cmp
|
||||||
from homeassistant.components.device_automation import condition as device_condition
|
from homeassistant.components.device_automation import condition as device_condition
|
||||||
|
@ -80,7 +80,7 @@ INPUT_ENTITY_ID = re.compile(
|
||||||
r"^input_(?:select|text|number|boolean|datetime)\.(?!.+__)(?!_)[\da-z_]+(?<!_)$"
|
r"^input_(?:select|text|number|boolean|datetime)\.(?!.+__)(?!_)[\da-z_]+(?<!_)$"
|
||||||
)
|
)
|
||||||
|
|
||||||
ConditionCheckerType = Callable[[HomeAssistant, TemplateVarsType], Optional[bool]]
|
ConditionCheckerType = Callable[[HomeAssistant, TemplateVarsType], bool | None]
|
||||||
|
|
||||||
|
|
||||||
def condition_trace_append(variables: TemplateVarsType, path: str) -> TraceElement:
|
def condition_trace_append(variables: TemplateVarsType, path: str) -> TraceElement:
|
||||||
|
|
|
@ -14,7 +14,7 @@ async def async_check_significant_change(
|
||||||
new_state: str,
|
new_state: str,
|
||||||
new_attrs: dict,
|
new_attrs: dict,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> Optional[bool]
|
) -> bool | None
|
||||||
```
|
```
|
||||||
|
|
||||||
Return boolean to indicate if significantly changed. If don't know, return None.
|
Return boolean to indicate if significantly changed. If don't know, return None.
|
||||||
|
@ -30,7 +30,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, Optional, Union
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
|
from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant, State, callback
|
from homeassistant.core import HomeAssistant, State, callback
|
||||||
|
@ -43,24 +43,24 @@ CheckTypeFunc = Callable[
|
||||||
[
|
[
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
str,
|
str,
|
||||||
Union[dict, MappingProxyType],
|
dict | MappingProxyType,
|
||||||
str,
|
str,
|
||||||
Union[dict, MappingProxyType],
|
dict | MappingProxyType,
|
||||||
],
|
],
|
||||||
Optional[bool],
|
bool | None,
|
||||||
]
|
]
|
||||||
|
|
||||||
ExtraCheckTypeFunc = Callable[
|
ExtraCheckTypeFunc = Callable[
|
||||||
[
|
[
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
str,
|
str,
|
||||||
Union[dict, MappingProxyType],
|
dict | MappingProxyType,
|
||||||
Any,
|
Any,
|
||||||
str,
|
str,
|
||||||
Union[dict, MappingProxyType],
|
dict | MappingProxyType,
|
||||||
Any,
|
Any,
|
||||||
],
|
],
|
||||||
Optional[bool],
|
bool | None,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue