mirror of
https://github.com/home-assistant/core.git
synced 2026-08-03 20:24:55 +02:00
Enable ruff rule RUF036 (none-not-at-end-of-union) (#177543)
This commit is contained in:
@@ -181,8 +181,8 @@ class AITaskPreferences:
|
||||
def async_set_preferences(
|
||||
self,
|
||||
*,
|
||||
gen_data_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
gen_image_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
gen_data_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
gen_image_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> None:
|
||||
"""Set the preferences."""
|
||||
changed = False
|
||||
|
||||
@@ -342,13 +342,13 @@ async def async_update_pipeline(
|
||||
conversation_language: str | UndefinedType = UNDEFINED,
|
||||
language: str | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
stt_engine: str | None | UndefinedType = UNDEFINED,
|
||||
stt_language: str | None | UndefinedType = UNDEFINED,
|
||||
tts_engine: str | None | UndefinedType = UNDEFINED,
|
||||
tts_language: str | None | UndefinedType = UNDEFINED,
|
||||
tts_voice: str | None | UndefinedType = UNDEFINED,
|
||||
wake_word_entity: str | None | UndefinedType = UNDEFINED,
|
||||
wake_word_id: str | None | UndefinedType = UNDEFINED,
|
||||
stt_engine: str | UndefinedType | None = UNDEFINED,
|
||||
stt_language: str | UndefinedType | None = UNDEFINED,
|
||||
tts_engine: str | UndefinedType | None = UNDEFINED,
|
||||
tts_language: str | UndefinedType | None = UNDEFINED,
|
||||
tts_voice: str | UndefinedType | None = UNDEFINED,
|
||||
wake_word_entity: str | UndefinedType | None = UNDEFINED,
|
||||
wake_word_id: str | UndefinedType | None = UNDEFINED,
|
||||
prefer_local_intents: bool | UndefinedType = UNDEFINED,
|
||||
) -> None:
|
||||
"""Update a pipeline."""
|
||||
|
||||
@@ -175,12 +175,12 @@ class CloudPreferences:
|
||||
google_connected: bool | UndefinedType = UNDEFINED,
|
||||
google_enabled: bool | UndefinedType = UNDEFINED,
|
||||
google_report_state: bool | UndefinedType = UNDEFINED,
|
||||
google_secure_devices_pin: str | None | UndefinedType = UNDEFINED,
|
||||
google_secure_devices_pin: str | UndefinedType | None = UNDEFINED,
|
||||
google_settings_version: int | UndefinedType = UNDEFINED,
|
||||
remote_allow_remote_enable: bool | UndefinedType = UNDEFINED,
|
||||
remote_domain: str | None | UndefinedType = UNDEFINED,
|
||||
remote_domain: str | UndefinedType | None = UNDEFINED,
|
||||
onboarded_items: list[str] | UndefinedType = UNDEFINED,
|
||||
onboarding_postponed_until: str | None | UndefinedType = UNDEFINED,
|
||||
onboarding_postponed_until: str | UndefinedType | None = UNDEFINED,
|
||||
remote_enabled: bool | UndefinedType = UNDEFINED,
|
||||
tts_default_voice: tuple[str, str] | UndefinedType = UNDEFINED,
|
||||
) -> None:
|
||||
|
||||
@@ -12,7 +12,7 @@ async def update_duckdns(
|
||||
domain: str,
|
||||
token: str,
|
||||
*,
|
||||
txt: str | None | UndefinedType = UNDEFINED,
|
||||
txt: str | UndefinedType | None = UNDEFINED,
|
||||
clear: bool = False,
|
||||
) -> bool:
|
||||
"""Update DuckDNS."""
|
||||
|
||||
@@ -269,7 +269,7 @@ class HomeConnectSwitch(HomeConnectEntity, SwitchEntity):
|
||||
class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
||||
"""Power switch class for Home Connect."""
|
||||
|
||||
power_off_state: str | None | UndefinedType = UNDEFINED
|
||||
power_off_state: str | UndefinedType | None = UNDEFINED
|
||||
|
||||
@override
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
|
||||
@@ -203,7 +203,7 @@ class ImageEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
# Entity Properties
|
||||
_attr_content_type: str = DEFAULT_CONTENT_TYPE
|
||||
_attr_image_last_updated: datetime | None = None
|
||||
_attr_image_url: str | None | UndefinedType = UNDEFINED
|
||||
_attr_image_url: str | UndefinedType | None = UNDEFINED
|
||||
_attr_should_poll: bool = False # No need to poll image entities
|
||||
_attr_state: None = None # State is determined by last_updated
|
||||
_cached_image: Image | None = None
|
||||
@@ -233,7 +233,7 @@ class ImageEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
return self._attr_image_last_updated
|
||||
|
||||
@cached_property
|
||||
def image_url(self) -> str | None | UndefinedType:
|
||||
def image_url(self) -> str | UndefinedType | None:
|
||||
"""Return URL of image."""
|
||||
return self._attr_image_url
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ async def _execute_realtime_action(
|
||||
target_soc: int,
|
||||
) -> None:
|
||||
"""Execute async_execute_realtime_action on all coordinators concurrently."""
|
||||
results: list[None | BaseException] = await asyncio.gather(
|
||||
results: list[BaseException | None] = await asyncio.gather(
|
||||
*(
|
||||
coordinator.async_realtime_action(action, power, target_soc)
|
||||
for coordinator in coordinators
|
||||
|
||||
@@ -130,7 +130,7 @@ class DemoSensor(SensorEntity):
|
||||
device_unique_id: str,
|
||||
unique_id: str,
|
||||
device_name: str,
|
||||
entity_name: str | None | UndefinedType,
|
||||
entity_name: str | UndefinedType | None,
|
||||
state: StateType,
|
||||
device_class: SensorDeviceClass | None,
|
||||
state_class: SensorStateClass | None,
|
||||
|
||||
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
|
||||
from .knx_module import KNXModule
|
||||
|
||||
|
||||
def _stable_group_address_repr(part: DeviceGroupAddress | None | int | str) -> str:
|
||||
def _stable_group_address_repr(part: DeviceGroupAddress | int | str | None) -> str:
|
||||
"""Render a unique_id part independent of `GroupAddress.address_format`."""
|
||||
if isinstance(part, GroupAddress):
|
||||
# Always LONG (main/middle/sub) derived from raw, so the representation
|
||||
@@ -39,7 +39,7 @@ def _stable_group_address_repr(part: DeviceGroupAddress | None | int | str) -> s
|
||||
|
||||
|
||||
def build_yaml_unique_id(
|
||||
*parts: DeviceGroupAddress | None | int | str,
|
||||
*parts: DeviceGroupAddress | int | str | None,
|
||||
) -> tuple[str, str]:
|
||||
"""Return `(new_stable_id, legacy_id)` for a YAML entity.
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ async def async_search_media(
|
||||
async def async_resolve_media(
|
||||
hass: HomeAssistant,
|
||||
media_content_id: str,
|
||||
target_media_player: str | None | UndefinedType = UNDEFINED,
|
||||
target_media_player: str | UndefinedType | None = UNDEFINED,
|
||||
) -> PlayMedia:
|
||||
"""Get info to play media."""
|
||||
if DOMAIN not in hass.config.top_level_components:
|
||||
|
||||
@@ -1266,7 +1266,7 @@ class PlatformField:
|
||||
required: bool
|
||||
validator: Callable[[Any], Any] | None = None
|
||||
error: str | None = None
|
||||
default: Any | None | Callable[[dict[str, Any]], Any] | vol.Undefined = (
|
||||
default: Any | Callable[[dict[str, Any]], Any] | vol.Undefined | None = (
|
||||
vol.UNDEFINED
|
||||
)
|
||||
is_schema_default: bool = False
|
||||
|
||||
@@ -1601,7 +1601,7 @@ class MqttEntity(
|
||||
|
||||
def _set_entity_name(self, config: ConfigType) -> None:
|
||||
"""Help setting the entity name if needed."""
|
||||
entity_name: str | None | UndefinedType = config.get(CONF_NAME, UNDEFINED)
|
||||
entity_name: str | UndefinedType | None = config.get(CONF_NAME, UNDEFINED)
|
||||
# Only set _attr_name if it is needed
|
||||
if entity_name is not UNDEFINED:
|
||||
self._attr_name = entity_name
|
||||
|
||||
@@ -28,7 +28,7 @@ class PropertySensorEntityDescription(SensorEntityDescription):
|
||||
|
||||
client_property: str
|
||||
property_map: dict[StateType, str] | None = None
|
||||
presence_flag: None | str = None
|
||||
presence_flag: str | None = None
|
||||
|
||||
|
||||
PROPERTY_SENSOR_DESCRIPTIONS: list[PropertySensorEntityDescription] = [
|
||||
|
||||
@@ -42,7 +42,7 @@ class PortainerEndpointButtonDescription(ButtonEntityDescription):
|
||||
|
||||
press_action: Callable[
|
||||
[Portainer, int],
|
||||
Coroutine[Any, Any, None | DockerContainer],
|
||||
Coroutine[Any, Any, DockerContainer | None],
|
||||
]
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class PortainerContainerButtonDescription(ButtonEntityDescription):
|
||||
|
||||
press_action: Callable[
|
||||
[Portainer, int, str],
|
||||
Coroutine[Any, Any, None | DockerContainer],
|
||||
Coroutine[Any, Any, DockerContainer | None],
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ T = TypeVar(
|
||||
bound=PrinterStatus
|
||||
| LegacyPrinterStatus
|
||||
| JobInfo
|
||||
| None
|
||||
| PrinterInfo
|
||||
| VersionInfo,
|
||||
| VersionInfo
|
||||
| None,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -566,8 +566,8 @@ class Recorder(threading.Thread):
|
||||
statistic_id: str,
|
||||
*,
|
||||
new_statistic_id: str | UndefinedType = UNDEFINED,
|
||||
new_unit_class: str | None | UndefinedType = UNDEFINED,
|
||||
new_unit_of_measurement: str | None | UndefinedType = UNDEFINED,
|
||||
new_unit_class: str | UndefinedType | None = UNDEFINED,
|
||||
new_unit_of_measurement: str | UndefinedType | None = UNDEFINED,
|
||||
on_done: Callable[[], None] | None = None,
|
||||
) -> None:
|
||||
"""Update statistics metadata for a statistic_id."""
|
||||
|
||||
@@ -979,8 +979,8 @@ def async_update_statistics_metadata(
|
||||
statistic_id: str,
|
||||
*,
|
||||
new_statistic_id: str | UndefinedType = UNDEFINED,
|
||||
new_unit_class: str | None | UndefinedType = UNDEFINED,
|
||||
new_unit_of_measurement: str | None | UndefinedType = UNDEFINED,
|
||||
new_unit_class: str | UndefinedType | None = UNDEFINED,
|
||||
new_unit_of_measurement: str | UndefinedType | None = UNDEFINED,
|
||||
on_done: Callable[[], None] | None = None,
|
||||
_called_from_ws_api: bool = False,
|
||||
) -> None:
|
||||
@@ -1028,9 +1028,9 @@ def async_update_statistics_metadata(
|
||||
def update_statistics_metadata(
|
||||
instance: Recorder,
|
||||
statistic_id: str,
|
||||
new_statistic_id: str | None | UndefinedType,
|
||||
new_unit_class: str | None | UndefinedType,
|
||||
new_unit_of_measurement: str | None | UndefinedType,
|
||||
new_statistic_id: str | UndefinedType | None,
|
||||
new_unit_class: str | UndefinedType | None,
|
||||
new_unit_of_measurement: str | UndefinedType | None,
|
||||
) -> None:
|
||||
"""Update statistics metadata for a statistic_id."""
|
||||
statistics_meta_manager = instance.statistics_meta_manager
|
||||
|
||||
@@ -76,9 +76,9 @@ class UpdateStatisticsMetadataTask(RecorderTask):
|
||||
|
||||
on_done: Callable[[], None] | None
|
||||
statistic_id: str
|
||||
new_statistic_id: str | None | UndefinedType
|
||||
new_unit_class: str | None | UndefinedType
|
||||
new_unit_of_measurement: str | None | UndefinedType
|
||||
new_statistic_id: str | UndefinedType | None
|
||||
new_unit_class: str | UndefinedType | None
|
||||
new_unit_of_measurement: str | UndefinedType | None
|
||||
|
||||
@override
|
||||
def run(self, instance: Recorder) -> None:
|
||||
|
||||
@@ -209,7 +209,7 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
_invalid_unit_of_measurement_reported = False
|
||||
_last_reset_reported = False
|
||||
_sensor_option_display_precision: int | None = None
|
||||
_sensor_option_unit_of_measurement: str | None | UndefinedType = UNDEFINED
|
||||
_sensor_option_unit_of_measurement: str | UndefinedType | None = UNDEFINED
|
||||
_invalid_suggested_unit_of_measurement_reported = False
|
||||
_get_uptime: Callable[[datetime], datetime] | None = None
|
||||
|
||||
@@ -910,7 +910,7 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
|
||||
def _custom_unit_or_undef(
|
||||
self, primary_key: str, secondary_key: str
|
||||
) -> str | None | UndefinedType:
|
||||
) -> str | UndefinedType | None:
|
||||
"""Return a custom unit, or UNDEFINED if not compatible with the native unit."""
|
||||
assert self.registry_entry
|
||||
if (
|
||||
|
||||
@@ -359,7 +359,7 @@ def _normalize_states(
|
||||
|
||||
valid_fstates: list[tuple[float, State]] = []
|
||||
convert: Callable[[float], float] | None = None
|
||||
last_unit: str | None | UndefinedType = UNDEFINED
|
||||
last_unit: str | UndefinedType | None = UNDEFINED
|
||||
valid_units = converter.VALID_UNITS
|
||||
|
||||
for fstate, state in fstates:
|
||||
|
||||
@@ -87,7 +87,7 @@ class ServerStatusUpdateLMS(ServerStatusUpdate):
|
||||
|
||||
@property
|
||||
@override
|
||||
def release_summary(self) -> None | str:
|
||||
def release_summary(self) -> str | None:
|
||||
"""If install is supported give some info."""
|
||||
return (
|
||||
str(self.coordinator.data[UPDATE_RELEASE_SUMMARY])
|
||||
@@ -117,7 +117,7 @@ class ServerStatusUpdatePlugins(ServerStatusUpdate):
|
||||
|
||||
@property
|
||||
@override
|
||||
def release_summary(self) -> None | str:
|
||||
def release_summary(self) -> str | None:
|
||||
"""If install is supported give some info."""
|
||||
rs = self.coordinator.data[UPDATE_PLUGINS_RELEASE_SUMMARY]
|
||||
return (
|
||||
|
||||
@@ -37,7 +37,7 @@ def decide_duration(
|
||||
duration: int | None,
|
||||
zone_id: int,
|
||||
overlay_mode: str | None = None,
|
||||
) -> None | int:
|
||||
) -> int | None:
|
||||
"""Return correct duration based on overlay mode and tado config."""
|
||||
|
||||
# If we ended up with a timer but no duration, set a default duration
|
||||
|
||||
@@ -69,7 +69,7 @@ def _get_temperature_descriptions(
|
||||
|
||||
def _get_temperatures(
|
||||
coordinator: ToGrillCoordinator, alarm_type: AlarmType
|
||||
) -> tuple[None | float, None | float]:
|
||||
) -> tuple[float | None, float | None]:
|
||||
if not (packet := coordinator.get_packet(PacketA8Notify, probe_number)):
|
||||
return None, None
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ class CoordinatedTPLinkFeatureEntity(CoordinatedTPLinkEntity, ABC):
|
||||
# HA logic is to name entities based on the following logic:
|
||||
# _attr_name > translation.name > description.name
|
||||
# > device_class (if base platform supports).
|
||||
name: str | None | UndefinedType = UNDEFINED
|
||||
name: str | UndefinedType | None = UNDEFINED
|
||||
|
||||
# The state feature gets the device name or the child device
|
||||
# name if it's a child device
|
||||
|
||||
@@ -34,7 +34,7 @@ class YouLessSensorEntityDescription(SensorEntityDescription):
|
||||
"""Describes a YouLess sensor entity."""
|
||||
|
||||
device_group: str
|
||||
value_func: Callable[[YoulessAPI], float | None | str]
|
||||
value_func: Callable[[YoulessAPI], float | str | None]
|
||||
|
||||
|
||||
SENSOR_TYPES: tuple[YouLessSensorEntityDescription, ...] = (
|
||||
|
||||
@@ -2541,7 +2541,7 @@ class ConfigEntries:
|
||||
pref_disable_new_entities: bool | UndefinedType = UNDEFINED,
|
||||
pref_disable_polling: bool | UndefinedType = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
version: int | UndefinedType = UNDEFINED,
|
||||
) -> bool:
|
||||
"""Update a config entry.
|
||||
@@ -2580,7 +2580,7 @@ class ConfigEntries:
|
||||
pref_disable_polling: bool | UndefinedType = UNDEFINED,
|
||||
subentries: dict[str, ConfigSubentry] | UndefinedType = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
version: int | UndefinedType = UNDEFINED,
|
||||
) -> bool:
|
||||
"""Update a config entry.
|
||||
@@ -2707,7 +2707,7 @@ class ConfigEntries:
|
||||
*,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> bool:
|
||||
"""Update a config subentry.
|
||||
|
||||
@@ -3461,7 +3461,7 @@ class ConfigFlow(ConfigEntryBaseFlow):
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType,
|
||||
unique_id: str | UndefinedType | None,
|
||||
title: str | UndefinedType,
|
||||
data: Mapping[str, Any] | UndefinedType,
|
||||
data_updates: Mapping[str, Any] | UndefinedType,
|
||||
@@ -3490,7 +3490,7 @@ class ConfigFlow(ConfigEntryBaseFlow):
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
data_updates: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
@@ -3532,7 +3532,7 @@ class ConfigFlow(ConfigEntryBaseFlow):
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
data_updates: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
@@ -3771,7 +3771,7 @@ class ConfigSubentryFlow(
|
||||
entry: ConfigEntry,
|
||||
subentry: ConfigSubentry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
data_updates: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
@@ -3800,7 +3800,7 @@ class ConfigSubentryFlow(
|
||||
entry: ConfigEntry,
|
||||
subentry: ConfigSubentry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
data_updates: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
@@ -3829,7 +3829,7 @@ class ConfigSubentryFlow(
|
||||
entry: ConfigEntry,
|
||||
subentry: ConfigSubentry,
|
||||
*,
|
||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||
unique_id: str | UndefinedType | None = UNDEFINED,
|
||||
title: str | UndefinedType = UNDEFINED,
|
||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
data_updates: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||
|
||||
@@ -349,13 +349,13 @@ class AreaRegistry(BaseRegistry[AreasRegistryStoreData]):
|
||||
area_id: str,
|
||||
*,
|
||||
aliases: set[str] | UndefinedType = UNDEFINED,
|
||||
floor_id: str | None | UndefinedType = UNDEFINED,
|
||||
humidity_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
floor_id: str | UndefinedType | None = UNDEFINED,
|
||||
humidity_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
picture: str | None | UndefinedType = UNDEFINED,
|
||||
temperature_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
picture: str | UndefinedType | None = UNDEFINED,
|
||||
temperature_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> AreaEntry:
|
||||
"""Update name of area."""
|
||||
updated = self._async_update(
|
||||
@@ -385,13 +385,13 @@ class AreaRegistry(BaseRegistry[AreasRegistryStoreData]):
|
||||
area_id: str,
|
||||
*,
|
||||
aliases: set[str] | UndefinedType = UNDEFINED,
|
||||
floor_id: str | None | UndefinedType = UNDEFINED,
|
||||
humidity_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
floor_id: str | UndefinedType | None = UNDEFINED,
|
||||
humidity_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
picture: str | None | UndefinedType = UNDEFINED,
|
||||
temperature_entity_id: str | None | UndefinedType = UNDEFINED,
|
||||
picture: str | UndefinedType | None = UNDEFINED,
|
||||
temperature_entity_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> AreaEntry:
|
||||
"""Update name of area."""
|
||||
old = self.areas[area_id]
|
||||
|
||||
@@ -32,7 +32,7 @@ class DomainSpec:
|
||||
Used by triggers and conditions.
|
||||
"""
|
||||
|
||||
device_class: str | None | AnyDeviceClassType = ANY_DEVICE_CLASS
|
||||
device_class: str | AnyDeviceClassType | None = ANY_DEVICE_CLASS
|
||||
value_source: str | None = None
|
||||
"""Attribute name to extract the value from, or None for state.state."""
|
||||
|
||||
@@ -143,7 +143,7 @@ class ThresholdConfig:
|
||||
numerical: bool
|
||||
entity: str | None
|
||||
number: float | None
|
||||
unit: str | None | UndefinedType
|
||||
unit: str | UndefinedType | None
|
||||
|
||||
@classmethod
|
||||
def from_config(cls, config: dict[str, Any] | None) -> Self | None:
|
||||
@@ -153,7 +153,7 @@ class ThresholdConfig:
|
||||
|
||||
entity: str | None = None
|
||||
number: float | None = None
|
||||
unit: str | None | UndefinedType = UNDEFINED
|
||||
unit: str | UndefinedType | None = UNDEFINED
|
||||
numerical = "number" in config
|
||||
if numerical:
|
||||
number = config["number"]
|
||||
|
||||
@@ -171,7 +171,7 @@ class CategoryRegistry(BaseRegistry[CategoryRegistryStoreData]):
|
||||
*,
|
||||
scope: str,
|
||||
category_id: str,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
) -> CategoryEntry:
|
||||
"""Update name or icon of the category."""
|
||||
|
||||
@@ -960,7 +960,7 @@ class EntityNumericalConditionBase(EntityConditionBase):
|
||||
"""Condition for numerical state comparisons with above/below thresholds."""
|
||||
|
||||
_schema = NUMERICAL_CONDITION_SCHEMA
|
||||
_valid_unit: str | None | UndefinedType = UNDEFINED
|
||||
_valid_unit: str | UndefinedType | None = UNDEFINED
|
||||
|
||||
def __init__(self, hass: HomeAssistant, config: ConditionConfig) -> None:
|
||||
"""Initialize the numerical condition."""
|
||||
@@ -1051,7 +1051,7 @@ class EntityNumericalConditionBase(EntityConditionBase):
|
||||
|
||||
def make_entity_numerical_condition(
|
||||
domain_specs: Mapping[str, DomainSpec] | str,
|
||||
valid_unit: str | None | UndefinedType = UNDEFINED,
|
||||
valid_unit: str | UndefinedType | None = UNDEFINED,
|
||||
*,
|
||||
primary_entities_only: bool = True,
|
||||
) -> type[EntityNumericalConditionBase]:
|
||||
|
||||
@@ -291,20 +291,20 @@ def _determine_device_info_type(
|
||||
class _ValidatedDeviceInfoFields(TypedDict):
|
||||
"""Device info fields validated on create and update."""
|
||||
|
||||
configuration_url: str | URL | None | UndefinedType
|
||||
hw_version: str | None | UndefinedType
|
||||
manufacturer: str | None | UndefinedType
|
||||
model: str | None | UndefinedType
|
||||
model_id: str | None | UndefinedType
|
||||
serial_number: str | None | UndefinedType
|
||||
sw_version: str | None | UndefinedType
|
||||
configuration_url: str | URL | UndefinedType | None
|
||||
hw_version: str | UndefinedType | None
|
||||
manufacturer: str | UndefinedType | None
|
||||
model: str | UndefinedType | None
|
||||
model_id: str | UndefinedType | None
|
||||
serial_number: str | UndefinedType | None
|
||||
sw_version: str | UndefinedType | None
|
||||
|
||||
|
||||
_cached_parse_url = lru_cache(maxsize=512)(URL)
|
||||
"""Parse a URL and cache the result."""
|
||||
|
||||
|
||||
def _validate_str(name: str, value: Any) -> str | None | UndefinedType:
|
||||
def _validate_str(name: str, value: Any) -> str | UndefinedType | None:
|
||||
"""Validate that a device registry string field has correct type."""
|
||||
if (
|
||||
value is UNDEFINED
|
||||
@@ -1149,7 +1149,7 @@ class DeviceRegistryItems[_EntryTypeT: (DeviceEntry, DeletedDeviceEntry)](
|
||||
identifiers: set[tuple[str, str]] | None = None,
|
||||
connections: set[tuple[str, str]] | None = None,
|
||||
*,
|
||||
config_entry_id: str | None | UndefinedType = UNDEFINED,
|
||||
config_entry_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> _EntryTypeT | None:
|
||||
"""Get the first entry matching identifiers or connections.
|
||||
|
||||
@@ -1741,32 +1741,32 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
self,
|
||||
*,
|
||||
config_entry_id: str,
|
||||
config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
configuration_url: str | URL | None | UndefinedType = UNDEFINED,
|
||||
connections: set[tuple[str, str]] | None | UndefinedType = UNDEFINED,
|
||||
config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
configuration_url: str | URL | UndefinedType | None = UNDEFINED,
|
||||
connections: set[tuple[str, str]] | UndefinedType | None = UNDEFINED,
|
||||
created_at: str | datetime | UndefinedType = UNDEFINED, # will be ignored
|
||||
default_manufacturer: str | None | UndefinedType = UNDEFINED,
|
||||
default_model: str | None | UndefinedType = UNDEFINED,
|
||||
default_name: str | None | UndefinedType = UNDEFINED,
|
||||
default_manufacturer: str | UndefinedType | None = UNDEFINED,
|
||||
default_model: str | UndefinedType | None = UNDEFINED,
|
||||
default_name: str | UndefinedType | None = UNDEFINED,
|
||||
# To disable a device if it gets created, does not affect existing devices
|
||||
disabled_by: DeviceEntryDisabler | None | UndefinedType = UNDEFINED,
|
||||
entry_type: DeviceEntryType | None | UndefinedType = UNDEFINED,
|
||||
hw_version: str | None | UndefinedType = UNDEFINED,
|
||||
identifiers: set[tuple[str, str]] | None | UndefinedType = UNDEFINED,
|
||||
manufacturer: str | None | UndefinedType = UNDEFINED,
|
||||
model: str | None | UndefinedType = UNDEFINED,
|
||||
model_id: str | None | UndefinedType = UNDEFINED,
|
||||
disabled_by: DeviceEntryDisabler | UndefinedType | None = UNDEFINED,
|
||||
entry_type: DeviceEntryType | UndefinedType | None = UNDEFINED,
|
||||
hw_version: str | UndefinedType | None = UNDEFINED,
|
||||
identifiers: set[tuple[str, str]] | UndefinedType | None = UNDEFINED,
|
||||
manufacturer: str | UndefinedType | None = UNDEFINED,
|
||||
model: str | UndefinedType | None = UNDEFINED,
|
||||
model_id: str | UndefinedType | None = UNDEFINED,
|
||||
modified_at: str | datetime | UndefinedType = UNDEFINED, # will be ignored
|
||||
name: str | None | UndefinedType = UNDEFINED,
|
||||
serial_number: str | None | UndefinedType = UNDEFINED,
|
||||
suggested_area: str | None | UndefinedType = UNDEFINED,
|
||||
sw_version: str | None | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType | None = UNDEFINED,
|
||||
serial_number: str | UndefinedType | None = UNDEFINED,
|
||||
suggested_area: str | UndefinedType | None = UNDEFINED,
|
||||
sw_version: str | UndefinedType | None = UNDEFINED,
|
||||
translation_key: str | None = None,
|
||||
translation_placeholders: Mapping[str, str] | None = None,
|
||||
# via_device is deprecated and will be removed in HA Core 2027.8, use
|
||||
# via_device_id instead
|
||||
via_device: tuple[str, str] | None | UndefinedType = UNDEFINED,
|
||||
via_device_id: str | None | UndefinedType = UNDEFINED,
|
||||
via_device: tuple[str, str] | UndefinedType | None = UNDEFINED,
|
||||
via_device_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> DeviceEntry:
|
||||
"""Get device. Create if it doesn't exist."""
|
||||
default_manufacturer = _validate_str(
|
||||
@@ -2040,37 +2040,37 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
device_id: str,
|
||||
*,
|
||||
add_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
add_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
add_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
# Only set when stripping colliding keys from a stale device: its retained
|
||||
# keys can still be duplicated in other stale devices and must not validate.
|
||||
allow_collisions: bool = False,
|
||||
area_id: str | None | UndefinedType = UNDEFINED,
|
||||
configuration_url: str | URL | None | UndefinedType = UNDEFINED,
|
||||
disabled_by: DeviceEntryDisabler | None | UndefinedType = UNDEFINED,
|
||||
entry_type: DeviceEntryType | None | UndefinedType = UNDEFINED,
|
||||
hw_version: str | None | UndefinedType = UNDEFINED,
|
||||
area_id: str | UndefinedType | None = UNDEFINED,
|
||||
configuration_url: str | URL | UndefinedType | None = UNDEFINED,
|
||||
disabled_by: DeviceEntryDisabler | UndefinedType | None = UNDEFINED,
|
||||
entry_type: DeviceEntryType | UndefinedType | None = UNDEFINED,
|
||||
hw_version: str | UndefinedType | None = UNDEFINED,
|
||||
is_new: bool = False,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
manufacturer: str | None | UndefinedType = UNDEFINED,
|
||||
manufacturer: str | UndefinedType | None = UNDEFINED,
|
||||
merge_connections: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
merge_identifiers: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
model: str | None | UndefinedType = UNDEFINED,
|
||||
model_id: str | None | UndefinedType = UNDEFINED,
|
||||
name_by_user: str | None | UndefinedType = UNDEFINED,
|
||||
name: str | None | UndefinedType = UNDEFINED,
|
||||
model: str | UndefinedType | None = UNDEFINED,
|
||||
model_id: str | UndefinedType | None = UNDEFINED,
|
||||
name_by_user: str | UndefinedType | None = UNDEFINED,
|
||||
name: str | UndefinedType | None = UNDEFINED,
|
||||
# has_composite_identifiers can be removed in HA Core 2027.8
|
||||
has_composite_identifiers: bool | UndefinedType = UNDEFINED,
|
||||
new_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
new_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
new_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
new_connections: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
new_identifiers: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
remove_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
remove_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
serial_number: str | None | UndefinedType = UNDEFINED,
|
||||
remove_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
serial_number: str | UndefinedType | None = UNDEFINED,
|
||||
# Can be removed when suggested_area is removed from DeviceEntry
|
||||
suggested_area: str | None | UndefinedType = UNDEFINED,
|
||||
sw_version: str | None | UndefinedType = UNDEFINED,
|
||||
via_device_id: str | None | UndefinedType = UNDEFINED,
|
||||
suggested_area: str | UndefinedType | None = UNDEFINED,
|
||||
sw_version: str | UndefinedType | None = UNDEFINED,
|
||||
via_device_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> DeviceEntry | None:
|
||||
"""Private update device attributes.
|
||||
|
||||
@@ -2173,8 +2173,8 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
# is one, otherwise it removes the device, since it has no other config entry.
|
||||
# - new_config_entry_id / new_config_subentry_id move the device immediately.
|
||||
target_config_entry_id: str | UndefinedType = UNDEFINED
|
||||
target_config_subentry_id: str | None | UndefinedType = UNDEFINED
|
||||
pending_move: _PendingMove | None | UndefinedType = UNDEFINED
|
||||
target_config_subentry_id: str | UndefinedType | None = UNDEFINED
|
||||
pending_move: _PendingMove | UndefinedType | None = UNDEFINED
|
||||
if new_config_entry_id is not UNDEFINED:
|
||||
target_config_entry_id = new_config_entry_id
|
||||
target_config_subentry_id = (
|
||||
@@ -2488,31 +2488,31 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
||||
device_id: str,
|
||||
*,
|
||||
add_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
add_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
area_id: str | None | UndefinedType = UNDEFINED,
|
||||
configuration_url: str | URL | None | UndefinedType = UNDEFINED,
|
||||
disabled_by: DeviceEntryDisabler | None | UndefinedType = UNDEFINED,
|
||||
entry_type: DeviceEntryType | None | UndefinedType = UNDEFINED,
|
||||
hw_version: str | None | UndefinedType = UNDEFINED,
|
||||
add_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
area_id: str | UndefinedType | None = UNDEFINED,
|
||||
configuration_url: str | URL | UndefinedType | None = UNDEFINED,
|
||||
disabled_by: DeviceEntryDisabler | UndefinedType | None = UNDEFINED,
|
||||
entry_type: DeviceEntryType | UndefinedType | None = UNDEFINED,
|
||||
hw_version: str | UndefinedType | None = UNDEFINED,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
manufacturer: str | None | UndefinedType = UNDEFINED,
|
||||
manufacturer: str | UndefinedType | None = UNDEFINED,
|
||||
merge_connections: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
merge_identifiers: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
model: str | None | UndefinedType = UNDEFINED,
|
||||
model_id: str | None | UndefinedType = UNDEFINED,
|
||||
name_by_user: str | None | UndefinedType = UNDEFINED,
|
||||
name: str | None | UndefinedType = UNDEFINED,
|
||||
model: str | UndefinedType | None = UNDEFINED,
|
||||
model_id: str | UndefinedType | None = UNDEFINED,
|
||||
name_by_user: str | UndefinedType | None = UNDEFINED,
|
||||
name: str | UndefinedType | None = UNDEFINED,
|
||||
new_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
new_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
new_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
new_connections: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
new_identifiers: set[tuple[str, str]] | UndefinedType = UNDEFINED,
|
||||
remove_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
remove_config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
serial_number: str | None | UndefinedType = UNDEFINED,
|
||||
remove_config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
serial_number: str | UndefinedType | None = UNDEFINED,
|
||||
# suggested_area is deprecated and will be removed in 2026.9
|
||||
suggested_area: str | None | UndefinedType = UNDEFINED,
|
||||
sw_version: str | None | UndefinedType = UNDEFINED,
|
||||
via_device_id: str | None | UndefinedType = UNDEFINED,
|
||||
suggested_area: str | UndefinedType | None = UNDEFINED,
|
||||
sw_version: str | UndefinedType | None = UNDEFINED,
|
||||
via_device_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> DeviceEntry | None:
|
||||
"""Update device attributes.
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ type _DispatcherDataType[*_Ts] = dict[
|
||||
SignalType[*_Ts] | str,
|
||||
dict[
|
||||
Callable[[*_Ts], Any] | Callable[..., Any],
|
||||
HassJob[..., None | Coroutine[Any, Any, None]] | None,
|
||||
HassJob[..., Coroutine[Any, Any, None] | None] | None,
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ def get_device_class(hass: HomeAssistant, entity_id: str) -> str | None:
|
||||
|
||||
def get_device_class_or_undefined(
|
||||
hass: HomeAssistant, entity_id: str
|
||||
) -> str | None | UndefinedType:
|
||||
) -> str | UndefinedType | None:
|
||||
"""Get the device class of an entity or UNDEFINED if not found."""
|
||||
try:
|
||||
return get_device_class(hass, entity_id)
|
||||
|
||||
@@ -499,7 +499,7 @@ def _async_get_full_entity_name(
|
||||
has_entity_name: bool,
|
||||
name: str | None,
|
||||
original_name: str | None,
|
||||
original_name_unprefixed: str | None | UndefinedType = UNDEFINED,
|
||||
original_name_unprefixed: str | UndefinedType | None = UNDEFINED,
|
||||
overridden_name: str | None = None,
|
||||
parts: Sequence[EntityNamePart],
|
||||
unprefix_name: bool = False,
|
||||
@@ -582,10 +582,10 @@ def _async_get_full_entity_name(
|
||||
def async_get_full_entity_name(
|
||||
hass: HomeAssistant,
|
||||
entry: RegistryEntry,
|
||||
original_name: str | None | UndefinedType = UNDEFINED,
|
||||
original_name: str | UndefinedType | None = UNDEFINED,
|
||||
) -> str:
|
||||
"""Get full entity name for an entry."""
|
||||
original_name_unprefixed: str | None | UndefinedType = UNDEFINED
|
||||
original_name_unprefixed: str | UndefinedType | None = UNDEFINED
|
||||
if original_name is UNDEFINED or original_name == entry.original_name:
|
||||
original_name = entry.original_name
|
||||
original_name_unprefixed = entry.original_name_unprefixed
|
||||
@@ -1114,12 +1114,12 @@ def _validate_item(
|
||||
domain: str,
|
||||
platform: str,
|
||||
*,
|
||||
config_entry_id: str | None | UndefinedType = None,
|
||||
config_subentry_id: str | None | UndefinedType = None,
|
||||
device_id: str | None | UndefinedType = None,
|
||||
disabled_by: RegistryEntryDisabler | None | UndefinedType = None,
|
||||
entity_category: EntityCategory | None | UndefinedType = None,
|
||||
hidden_by: RegistryEntryHider | None | UndefinedType = None,
|
||||
config_entry_id: str | UndefinedType | None = None,
|
||||
config_subentry_id: str | UndefinedType | None = None,
|
||||
device_id: str | UndefinedType | None = None,
|
||||
disabled_by: RegistryEntryDisabler | UndefinedType | None = None,
|
||||
entity_category: EntityCategory | UndefinedType | None = None,
|
||||
hidden_by: RegistryEntryHider | UndefinedType | None = None,
|
||||
old_config_subentry_id: str | None = None,
|
||||
report_non_string_unique_id: bool = True,
|
||||
unique_id: str | Hashable | UndefinedType | Any,
|
||||
@@ -1420,8 +1420,8 @@ class EntityRegistry(BaseRegistry):
|
||||
*,
|
||||
# Used for entity ID generation, if entity gets created.
|
||||
# `suggested_object_id` has priority over `object_id_base`.
|
||||
object_id_base: str | None | UndefinedType = UNDEFINED,
|
||||
suggested_object_id: str | None | UndefinedType = UNDEFINED,
|
||||
object_id_base: str | UndefinedType | None = UNDEFINED,
|
||||
suggested_object_id: str | UndefinedType | None = UNDEFINED,
|
||||
# To disable or hide an entity if it gets created, does not affect
|
||||
# existing entities
|
||||
disabled_by: RegistryEntryDisabler | None = None,
|
||||
@@ -1429,25 +1429,25 @@ class EntityRegistry(BaseRegistry):
|
||||
# Function to generate initial entity options if it gets created
|
||||
get_initial_options: Callable[[], EntityOptionsType | None] | None = None,
|
||||
# Data that we want entry to have
|
||||
capabilities: Mapping[str, Any] | None | UndefinedType = UNDEFINED,
|
||||
config_entry: ConfigEntry | None | UndefinedType = UNDEFINED,
|
||||
config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
device_id: str | None | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | UndefinedType | None = UNDEFINED,
|
||||
config_entry: ConfigEntry | UndefinedType | None = UNDEFINED,
|
||||
config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
device_id: str | UndefinedType | None = UNDEFINED,
|
||||
entity_category: EntityCategory | UndefinedType | None = UNDEFINED,
|
||||
has_entity_name: bool | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | None | UndefinedType = UNDEFINED,
|
||||
original_icon: str | None | UndefinedType = UNDEFINED,
|
||||
original_name: str | None | UndefinedType = UNDEFINED,
|
||||
supported_features: int | None | UndefinedType = UNDEFINED,
|
||||
translation_key: str | None | UndefinedType = UNDEFINED,
|
||||
unit_of_measurement: str | None | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | UndefinedType | None = UNDEFINED,
|
||||
original_icon: str | UndefinedType | None = UNDEFINED,
|
||||
original_name: str | UndefinedType | None = UNDEFINED,
|
||||
supported_features: int | UndefinedType | None = UNDEFINED,
|
||||
translation_key: str | UndefinedType | None = UNDEFINED,
|
||||
unit_of_measurement: str | UndefinedType | None = UNDEFINED,
|
||||
) -> RegistryEntry:
|
||||
"""Get entity. Create if it doesn't exist.
|
||||
|
||||
domain: entity component domain (e.g. light, sensor)
|
||||
platform: integration domain (e.g. hue, zwave)
|
||||
"""
|
||||
config_entry_id: str | None | UndefinedType = UNDEFINED
|
||||
config_entry_id: str | UndefinedType | None = UNDEFINED
|
||||
if not config_entry:
|
||||
config_entry_id = None
|
||||
elif config_entry is not UNDEFINED:
|
||||
@@ -1756,7 +1756,7 @@ class EntityRegistry(BaseRegistry):
|
||||
# An empty name_unprefixed means the entity name equals
|
||||
# the device name (e.g. a main sensor); a non-empty one
|
||||
# is appended as a suffix.
|
||||
name: str | None | UndefinedType = UNDEFINED
|
||||
name: str | UndefinedType | None = UNDEFINED
|
||||
if (
|
||||
by_user
|
||||
and entity.name is None
|
||||
@@ -1802,8 +1802,8 @@ class EntityRegistry(BaseRegistry):
|
||||
|
||||
@callback
|
||||
def _ignore_composite_device_id(
|
||||
self, platform: str, device_id: str | None | UndefinedType
|
||||
) -> str | None | UndefinedType:
|
||||
self, platform: str, device_id: str | UndefinedType | None
|
||||
) -> str | UndefinedType | None:
|
||||
"""Ignore a request to link an entity to a composite device id.
|
||||
|
||||
A pre-migration composite device was split into one device per config
|
||||
@@ -1838,33 +1838,33 @@ class EntityRegistry(BaseRegistry):
|
||||
entity_id: str,
|
||||
*,
|
||||
aliases: list[AliasEntry] | UndefinedType = UNDEFINED,
|
||||
area_id: str | None | UndefinedType = UNDEFINED,
|
||||
area_id: str | UndefinedType | None = UNDEFINED,
|
||||
categories: dict[str, str] | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | None | UndefinedType = UNDEFINED,
|
||||
config_entry_id: str | None | UndefinedType = UNDEFINED,
|
||||
config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
device_class: str | None | UndefinedType = UNDEFINED,
|
||||
device_id: str | None | UndefinedType = UNDEFINED,
|
||||
disabled_by: RegistryEntryDisabler | None | UndefinedType = UNDEFINED,
|
||||
entity_category: EntityCategory | None | UndefinedType = UNDEFINED,
|
||||
hidden_by: RegistryEntryHider | None | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | UndefinedType | None = UNDEFINED,
|
||||
config_entry_id: str | UndefinedType | None = UNDEFINED,
|
||||
config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
device_class: str | UndefinedType | None = UNDEFINED,
|
||||
device_id: str | UndefinedType | None = UNDEFINED,
|
||||
disabled_by: RegistryEntryDisabler | UndefinedType | None = UNDEFINED,
|
||||
entity_category: EntityCategory | UndefinedType | None = UNDEFINED,
|
||||
hidden_by: RegistryEntryHider | UndefinedType | None = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
has_entity_name: bool | UndefinedType = UNDEFINED,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
name: str | None | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType | None = UNDEFINED,
|
||||
new_entity_id: str | UndefinedType = UNDEFINED,
|
||||
new_unique_id: str | UndefinedType = UNDEFINED,
|
||||
object_id_base: str | None | UndefinedType = UNDEFINED,
|
||||
object_id_base: str | UndefinedType | None = UNDEFINED,
|
||||
options: EntityOptionsType | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | None | UndefinedType = UNDEFINED,
|
||||
original_icon: str | None | UndefinedType = UNDEFINED,
|
||||
original_name: str | None | UndefinedType = UNDEFINED,
|
||||
original_name_unprefixed: str | None | UndefinedType = UNDEFINED,
|
||||
platform: str | None | UndefinedType = UNDEFINED,
|
||||
suggested_object_id: str | None | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | UndefinedType | None = UNDEFINED,
|
||||
original_icon: str | UndefinedType | None = UNDEFINED,
|
||||
original_name: str | UndefinedType | None = UNDEFINED,
|
||||
original_name_unprefixed: str | UndefinedType | None = UNDEFINED,
|
||||
platform: str | UndefinedType | None = UNDEFINED,
|
||||
suggested_object_id: str | UndefinedType | None = UNDEFINED,
|
||||
supported_features: int | UndefinedType = UNDEFINED,
|
||||
translation_key: str | None | UndefinedType = UNDEFINED,
|
||||
unit_of_measurement: str | None | UndefinedType = UNDEFINED,
|
||||
translation_key: str | UndefinedType | None = UNDEFINED,
|
||||
unit_of_measurement: str | UndefinedType | None = UNDEFINED,
|
||||
) -> RegistryEntry:
|
||||
"""Private facing update properties method."""
|
||||
old = self.entities[entity_id]
|
||||
@@ -2015,28 +2015,28 @@ class EntityRegistry(BaseRegistry):
|
||||
entity_id: str,
|
||||
*,
|
||||
aliases: list[AliasEntry] | UndefinedType = UNDEFINED,
|
||||
area_id: str | None | UndefinedType = UNDEFINED,
|
||||
area_id: str | UndefinedType | None = UNDEFINED,
|
||||
categories: dict[str, str] | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | None | UndefinedType = UNDEFINED,
|
||||
config_entry_id: str | None | UndefinedType = UNDEFINED,
|
||||
config_subentry_id: str | None | UndefinedType = UNDEFINED,
|
||||
device_class: str | None | UndefinedType = UNDEFINED,
|
||||
device_id: str | None | UndefinedType = UNDEFINED,
|
||||
disabled_by: RegistryEntryDisabler | None | UndefinedType = UNDEFINED,
|
||||
entity_category: EntityCategory | None | UndefinedType = UNDEFINED,
|
||||
hidden_by: RegistryEntryHider | None | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
capabilities: Mapping[str, Any] | UndefinedType | None = UNDEFINED,
|
||||
config_entry_id: str | UndefinedType | None = UNDEFINED,
|
||||
config_subentry_id: str | UndefinedType | None = UNDEFINED,
|
||||
device_class: str | UndefinedType | None = UNDEFINED,
|
||||
device_id: str | UndefinedType | None = UNDEFINED,
|
||||
disabled_by: RegistryEntryDisabler | UndefinedType | None = UNDEFINED,
|
||||
entity_category: EntityCategory | UndefinedType | None = UNDEFINED,
|
||||
hidden_by: RegistryEntryHider | UndefinedType | None = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
has_entity_name: bool | UndefinedType = UNDEFINED,
|
||||
labels: set[str] | UndefinedType = UNDEFINED,
|
||||
name: str | None | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType | None = UNDEFINED,
|
||||
new_entity_id: str | UndefinedType = UNDEFINED,
|
||||
new_unique_id: str | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | None | UndefinedType = UNDEFINED,
|
||||
original_icon: str | None | UndefinedType = UNDEFINED,
|
||||
original_name: str | None | UndefinedType = UNDEFINED,
|
||||
original_device_class: str | UndefinedType | None = UNDEFINED,
|
||||
original_icon: str | UndefinedType | None = UNDEFINED,
|
||||
original_name: str | UndefinedType | None = UNDEFINED,
|
||||
supported_features: int | UndefinedType = UNDEFINED,
|
||||
translation_key: str | None | UndefinedType = UNDEFINED,
|
||||
unit_of_measurement: str | None | UndefinedType = UNDEFINED,
|
||||
translation_key: str | UndefinedType | None = UNDEFINED,
|
||||
unit_of_measurement: str | UndefinedType | None = UNDEFINED,
|
||||
) -> RegistryEntry:
|
||||
"""Update properties of an entity."""
|
||||
return self._async_update_entity(
|
||||
@@ -2075,7 +2075,7 @@ class EntityRegistry(BaseRegistry):
|
||||
new_config_entry_id: str | UndefinedType = UNDEFINED,
|
||||
new_config_subentry_id: str | UndefinedType = UNDEFINED,
|
||||
new_unique_id: str | UndefinedType = UNDEFINED,
|
||||
new_device_id: str | None | UndefinedType = UNDEFINED,
|
||||
new_device_id: str | UndefinedType | None = UNDEFINED,
|
||||
) -> RegistryEntry:
|
||||
"""Update entity platform.
|
||||
|
||||
@@ -2124,7 +2124,7 @@ class EntityRegistry(BaseRegistry):
|
||||
def async_update_settings(
|
||||
self,
|
||||
*,
|
||||
entity_id_parts: list[EntityNamePart] | None | UndefinedType = UNDEFINED,
|
||||
entity_id_parts: list[EntityNamePart] | UndefinedType | None = UNDEFINED,
|
||||
) -> EntityRegistrySettings:
|
||||
"""Update entity registry settings."""
|
||||
self.hass.verify_event_loop_thread("entity_registry.async_update_settings")
|
||||
|
||||
@@ -249,7 +249,7 @@ class FloorRegistry(BaseRegistry[FloorRegistryStoreData]):
|
||||
floor_id: str,
|
||||
*,
|
||||
aliases: set[str] | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
level: int | UndefinedType = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
) -> FloorEntry:
|
||||
|
||||
@@ -184,9 +184,9 @@ class LabelRegistry(BaseRegistry[LabelRegistryStoreData]):
|
||||
self,
|
||||
label_id: str,
|
||||
*,
|
||||
color: str | None | UndefinedType = UNDEFINED,
|
||||
description: str | None | UndefinedType = UNDEFINED,
|
||||
icon: str | None | UndefinedType = UNDEFINED,
|
||||
color: str | UndefinedType | None = UNDEFINED,
|
||||
description: str | UndefinedType | None = UNDEFINED,
|
||||
icon: str | UndefinedType | None = UNDEFINED,
|
||||
name: str | UndefinedType = UNDEFINED,
|
||||
) -> LabelEntry:
|
||||
"""Update name of label."""
|
||||
|
||||
@@ -79,8 +79,8 @@ class SchemaFlowFormStep(SchemaFlowStep):
|
||||
|
||||
suggested_values: (
|
||||
Callable[[SchemaCommonFlowHandler], Coroutine[Any, Any, dict[str, Any]]]
|
||||
| None
|
||||
| UndefinedType
|
||||
| None
|
||||
) = UNDEFINED
|
||||
"""Optional property to populate suggested values.
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ class _StopScript(_HaltScript):
|
||||
self,
|
||||
message: str,
|
||||
response: Any,
|
||||
conversation_response: str | None | UndefinedType = UNDEFINED,
|
||||
conversation_response: str | UndefinedType | None = UNDEFINED,
|
||||
) -> None:
|
||||
"""Initialize a halt exception."""
|
||||
super().__init__(message)
|
||||
@@ -457,7 +457,7 @@ class _ScriptRun:
|
||||
self._started = False
|
||||
self._stop = hass.loop.create_future()
|
||||
self._stopped = asyncio.Event()
|
||||
self._conversation_response: str | None | UndefinedType = UNDEFINED
|
||||
self._conversation_response: str | UndefinedType | None = UNDEFINED
|
||||
|
||||
def _changed(self) -> None:
|
||||
if not self._stop.done():
|
||||
@@ -1494,7 +1494,7 @@ class _IfData(TypedDict):
|
||||
class ScriptRunResult:
|
||||
"""Container with the result of a script run."""
|
||||
|
||||
conversation_response: str | None | UndefinedType
|
||||
conversation_response: str | UndefinedType | None
|
||||
service_response: ServiceResponse
|
||||
variables: Mapping[str, Any]
|
||||
|
||||
|
||||
@@ -817,7 +817,7 @@ NUMERICAL_ATTRIBUTE_CHANGED_TRIGGER_SCHEMA = ENTITY_STATE_TRIGGER_SCHEMA.extend(
|
||||
class EntityNumericalStateTriggerBase(EntityTriggerBase):
|
||||
"""Base class for numerical state and state attribute triggers."""
|
||||
|
||||
_valid_unit: str | None | UndefinedType = UNDEFINED
|
||||
_valid_unit: str | UndefinedType | None = UNDEFINED
|
||||
_threshold_type: NumericThresholdType
|
||||
|
||||
def __init__(self, hass: HomeAssistant, config: TriggerConfig) -> None:
|
||||
@@ -1282,7 +1282,7 @@ def make_entity_origin_state_trigger(
|
||||
|
||||
def make_entity_numerical_state_changed_trigger(
|
||||
domain_specs: Mapping[str, DomainSpec],
|
||||
valid_unit: str | None | UndefinedType = UNDEFINED,
|
||||
valid_unit: str | UndefinedType | None = UNDEFINED,
|
||||
*,
|
||||
primary_entities_only: bool = True,
|
||||
) -> type[EntityNumericalStateChangedTriggerBase]:
|
||||
@@ -1300,7 +1300,7 @@ def make_entity_numerical_state_changed_trigger(
|
||||
|
||||
def make_entity_numerical_state_crossed_threshold_trigger(
|
||||
domain_specs: Mapping[str, DomainSpec],
|
||||
valid_unit: str | None | UndefinedType = UNDEFINED,
|
||||
valid_unit: str | UndefinedType | None = UNDEFINED,
|
||||
*,
|
||||
primary_entities_only: bool = True,
|
||||
) -> type[EntityNumericalStateCrossedThresholdTriggerBase]:
|
||||
|
||||
@@ -75,7 +75,7 @@ class DataUpdateCoordinator(BaseDataUpdateCoordinatorProtocol, Generic[_DataT]):
|
||||
hass: HomeAssistant,
|
||||
logger: logging.Logger,
|
||||
*,
|
||||
config_entry: config_entries.ConfigEntry | None | UndefinedType = UNDEFINED,
|
||||
config_entry: config_entries.ConfigEntry | UndefinedType | None = UNDEFINED,
|
||||
name: str,
|
||||
update_interval: timedelta | None = None,
|
||||
update_method: Callable[[], Awaitable[_DataT]] | None = None,
|
||||
|
||||
@@ -1524,7 +1524,7 @@ async def _resolve_integrations_dependencies(
|
||||
integrations: Iterable[Integration],
|
||||
*,
|
||||
cache: _ResolveDependenciesCacheProtocol,
|
||||
possible_after_dependencies: set[str] | None | UndefinedType = UNDEFINED,
|
||||
possible_after_dependencies: set[str] | UndefinedType | None = UNDEFINED,
|
||||
ignore_exceptions: bool,
|
||||
) -> dict[str, set[str]]:
|
||||
"""Resolve all dependencies for integrations.
|
||||
@@ -1567,7 +1567,7 @@ async def _resolve_integration_dependencies(
|
||||
itg: Integration,
|
||||
*,
|
||||
cache: _ResolveDependenciesCacheProtocol,
|
||||
possible_after_dependencies: set[str] | None | UndefinedType = UNDEFINED,
|
||||
possible_after_dependencies: set[str] | UndefinedType | None = UNDEFINED,
|
||||
ignore_exceptions: bool = False,
|
||||
) -> set[str]:
|
||||
"""Recursively resolve all dependencies.
|
||||
|
||||
@@ -34,7 +34,7 @@ _TYPE_HINT_MATCHERS.update(
|
||||
|
||||
|
||||
def is_valid_type(
|
||||
expected_type: list[str] | str | None | object,
|
||||
expected_type: list[str] | str | object | None,
|
||||
node: nodes.NodeNG,
|
||||
in_return: bool = False,
|
||||
) -> bool:
|
||||
|
||||
@@ -782,7 +782,6 @@ ignore = [
|
||||
"FURB116",
|
||||
|
||||
# Disabled to implement in follow up PRs after ruff 0.16 bump
|
||||
"RUF036",
|
||||
"ISC004",
|
||||
"LOG004",
|
||||
"FURB192",
|
||||
|
||||
@@ -31,7 +31,7 @@ async def help_test_async_alarm_control_panel_service(
|
||||
hass: HomeAssistant,
|
||||
entity_id: str,
|
||||
service: str,
|
||||
code: str | None | UndefinedType = UNDEFINED,
|
||||
code: str | UndefinedType | None = UNDEFINED,
|
||||
) -> None:
|
||||
"""Help to lock a test lock."""
|
||||
data: dict[str, Any] = {"entity_id": entity_id}
|
||||
|
||||
@@ -690,8 +690,8 @@ async def test_calendar_initial_color_none(
|
||||
],
|
||||
)
|
||||
async def test_calendar_initial_color_precedence(
|
||||
description_color: str | None | object,
|
||||
attr_color: str | None | object,
|
||||
description_color: str | object | None,
|
||||
attr_color: str | object | None,
|
||||
expected_color: str | None,
|
||||
) -> None:
|
||||
"""Test that _attr_initial_color takes precedence over entity_description."""
|
||||
@@ -703,8 +703,8 @@ async def test_calendar_initial_color_precedence(
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
description_color: str | None | object,
|
||||
attr_color: str | None | object,
|
||||
description_color: str | object | None,
|
||||
attr_color: str | object | None,
|
||||
) -> None:
|
||||
"""Initialize entity."""
|
||||
self._attr_name = "Test"
|
||||
|
||||
+27
-27
@@ -253,9 +253,9 @@ def _parametrize_condition_states(
|
||||
*,
|
||||
condition: str,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
target_states: list[str | None | tuple[str | None, dict]],
|
||||
other_states: list[str | None | tuple[str | None, dict]],
|
||||
extra_excluded_states: list[str | None | tuple[str | None, dict]] | None = None,
|
||||
target_states: list[str | tuple[str | None, dict] | None],
|
||||
other_states: list[str | tuple[str | None, dict] | None],
|
||||
extra_excluded_states: list[str | tuple[str | None, dict] | None] | None = None,
|
||||
required_filter_attributes: dict | None,
|
||||
condition_true_if_invalid: bool,
|
||||
excluded_entities_from_other_domain: bool,
|
||||
@@ -277,7 +277,7 @@ def _parametrize_condition_states(
|
||||
)
|
||||
|
||||
def state_with_attributes(
|
||||
state: str | None | tuple[str | None, dict],
|
||||
state: str | tuple[str | None, dict] | None,
|
||||
condition_true: bool,
|
||||
condition_true_first_entity: bool,
|
||||
) -> ConditionStateDescription:
|
||||
@@ -363,9 +363,9 @@ def parametrize_condition_states_any(
|
||||
*,
|
||||
condition: str,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
target_states: list[str | None | tuple[str | None, dict]],
|
||||
other_states: list[str | None | tuple[str | None, dict]],
|
||||
extra_excluded_states: list[str | None | tuple[str | None, dict]] | None = None,
|
||||
target_states: list[str | tuple[str | None, dict] | None],
|
||||
other_states: list[str | tuple[str | None, dict] | None],
|
||||
extra_excluded_states: list[str | tuple[str | None, dict] | None] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
excluded_entities_from_other_domain: bool = False,
|
||||
) -> list[tuple[str, dict[str, Any], list[ConditionStateDescription]]]:
|
||||
@@ -422,9 +422,9 @@ def parametrize_condition_states_all(
|
||||
*,
|
||||
condition: str,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
target_states: list[str | None | tuple[str | None, dict]],
|
||||
other_states: list[str | None | tuple[str | None, dict]],
|
||||
extra_excluded_states: list[str | None | tuple[str | None, dict]] | None = None,
|
||||
target_states: list[str | tuple[str | None, dict] | None],
|
||||
other_states: list[str | tuple[str | None, dict] | None],
|
||||
extra_excluded_states: list[str | tuple[str | None, dict] | None] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
excluded_entities_from_other_domain: bool = False,
|
||||
) -> list[tuple[str, dict[str, Any], list[ConditionStateDescription]]]:
|
||||
@@ -484,10 +484,10 @@ def parametrize_trigger_states(
|
||||
*,
|
||||
trigger: str,
|
||||
trigger_options: dict[str, Any] | None = None,
|
||||
target_states: list[str | None | tuple[str | None, dict]],
|
||||
other_states: list[str | None | tuple[str | None, dict]],
|
||||
extra_excluded_states: list[str | None | tuple[str | None, dict]] | None = None,
|
||||
extra_invalid_states: list[str | None | tuple[str | None, dict]] | None = None,
|
||||
target_states: list[str | tuple[str | None, dict] | None],
|
||||
other_states: list[str | tuple[str | None, dict] | None],
|
||||
extra_excluded_states: list[str | tuple[str | None, dict] | None] | None = None,
|
||||
extra_invalid_states: list[str | tuple[str | None, dict] | None] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
trigger_from_none: bool = True,
|
||||
retrigger_on_target_state: bool = False,
|
||||
@@ -555,7 +555,7 @@ def parametrize_trigger_states(
|
||||
trigger_options = trigger_options or {}
|
||||
|
||||
def _included_state_desc(
|
||||
state: str | None | tuple[str | None, dict],
|
||||
state: str | tuple[str | None, dict] | None,
|
||||
) -> StateDescription:
|
||||
"""Build a state for entities meant to match the trigger's target.
|
||||
|
||||
@@ -570,7 +570,7 @@ def parametrize_trigger_states(
|
||||
}
|
||||
|
||||
def _excluded_state_desc(
|
||||
state: str | None | tuple[str | None, dict],
|
||||
state: str | tuple[str | None, dict] | None,
|
||||
) -> StateDescription:
|
||||
"""Build a state for entities outside the trigger's target.
|
||||
|
||||
@@ -589,10 +589,10 @@ def parametrize_trigger_states(
|
||||
}
|
||||
|
||||
def state_with_attributes(
|
||||
state: str | None | tuple[str | None, dict],
|
||||
state: str | tuple[str | None, dict] | None,
|
||||
count: int,
|
||||
*,
|
||||
others_state: str | None | tuple[str | None, dict] | UndefinedType = UNDEFINED,
|
||||
others_state: str | tuple[str | None, dict] | UndefinedType | None = UNDEFINED,
|
||||
) -> TriggerStateDescription:
|
||||
"""Return TriggerStateDescription dict."""
|
||||
included = _included_state_desc(state)
|
||||
@@ -819,7 +819,7 @@ def parametrize_trigger_states(
|
||||
|
||||
|
||||
def _add_threshold_unit(
|
||||
options: dict[str, Any], threshold_unit: str | None | UndefinedType
|
||||
options: dict[str, Any], threshold_unit: str | UndefinedType | None
|
||||
) -> dict[str, Any]:
|
||||
"""Add unit to trigger thresholds if threshold_unit is provided."""
|
||||
if threshold_unit is UNDEFINED:
|
||||
@@ -838,7 +838,7 @@ def parametrize_numerical_attribute_changed_trigger_states(
|
||||
state: str,
|
||||
attribute: str,
|
||||
*,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
trigger_options: dict[str, Any] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
unit_attributes: dict | None = None,
|
||||
@@ -984,7 +984,7 @@ def parametrize_numerical_attribute_crossed_threshold_trigger_states(
|
||||
state: str,
|
||||
attribute: str,
|
||||
*,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
trigger_options: dict[str, Any] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
unit_attributes: dict | None = None,
|
||||
@@ -1155,7 +1155,7 @@ def parametrize_numerical_state_value_changed_trigger_states(
|
||||
trigger: str,
|
||||
*,
|
||||
device_class: str,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
trigger_options: dict[str, Any] | None = None,
|
||||
unit_attributes: dict | None = None,
|
||||
) -> list[tuple[str, dict[str, Any], list[TriggerStateDescription]]]:
|
||||
@@ -1236,7 +1236,7 @@ def parametrize_numerical_state_value_crossed_threshold_trigger_states(
|
||||
trigger: str,
|
||||
*,
|
||||
device_class: str,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
trigger_options: dict[str, Any] | None = None,
|
||||
unit_attributes: dict | None = None,
|
||||
) -> list[tuple[str, dict[str, Any], list[TriggerStateDescription]]]:
|
||||
@@ -1889,7 +1889,7 @@ def parametrize_numerical_condition_above_below_any(
|
||||
*,
|
||||
device_class: str,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
unit_attributes: dict | None = None,
|
||||
) -> list[tuple[str, dict[str, Any], list[ConditionStateDescription]]]:
|
||||
"""Parametrize threshold cases for state-value numerical conditions.
|
||||
@@ -2012,7 +2012,7 @@ def parametrize_numerical_condition_above_below_all(
|
||||
*,
|
||||
device_class: str,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
unit_attributes: dict | None = None,
|
||||
) -> list[tuple[str, dict[str, Any], list[ConditionStateDescription]]]:
|
||||
"""Parametrize threshold cases for state-value numerical conditions.
|
||||
@@ -2132,7 +2132,7 @@ def parametrize_numerical_attribute_condition_above_below_any(
|
||||
*,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
unit_attributes: dict | None = None,
|
||||
attribute_required: bool = False,
|
||||
attribute_value_scale: float = 1.0,
|
||||
@@ -2280,7 +2280,7 @@ def parametrize_numerical_attribute_condition_above_below_all(
|
||||
*,
|
||||
condition_options: dict[str, Any] | None = None,
|
||||
required_filter_attributes: dict | None = None,
|
||||
threshold_unit: str | None | UndefinedType = UNDEFINED,
|
||||
threshold_unit: str | UndefinedType | None = UNDEFINED,
|
||||
unit_attributes: dict | None = None,
|
||||
attribute_required: bool = False,
|
||||
attribute_value_scale: float = 1.0,
|
||||
|
||||
@@ -623,7 +623,7 @@ async def test_power_switch_service_validation_errors(
|
||||
integration_setup: Callable[[MagicMock], Awaitable[bool]],
|
||||
exception_match: str,
|
||||
entity_id: str,
|
||||
allowed_values: list[str | None] | None | HomeConnectError,
|
||||
allowed_values: list[str | None] | HomeConnectError | None,
|
||||
service: str,
|
||||
) -> None:
|
||||
"""Test power switch functionality validation errors."""
|
||||
|
||||
@@ -27,7 +27,7 @@ async def help_test_async_lock_service(
|
||||
hass: HomeAssistant,
|
||||
entity_id: str,
|
||||
service: str,
|
||||
code: str | None | UndefinedType = UNDEFINED,
|
||||
code: str | UndefinedType | None = UNDEFINED,
|
||||
) -> None:
|
||||
"""Help to lock a test lock."""
|
||||
data: dict[str, Any] = {"entity_id": entity_id}
|
||||
|
||||
@@ -485,14 +485,14 @@ class MockMusicServiceItem:
|
||||
item_id: str,
|
||||
parent_id: str,
|
||||
item_class: str,
|
||||
album_art_uri: None | str = None,
|
||||
album_art_uri: str | None = None,
|
||||
) -> None:
|
||||
"""Initialize the mock item."""
|
||||
self.title = title
|
||||
self.item_id = item_id
|
||||
self.item_class = item_class
|
||||
self.parent_id = parent_id
|
||||
self.album_art_uri: None | str = album_art_uri
|
||||
self.album_art_uri: str | None = album_art_uri
|
||||
|
||||
def get_uri(self) -> str:
|
||||
"""Return URI."""
|
||||
|
||||
@@ -2007,7 +2007,7 @@ async def test_result_stream_message_set_idempotent(
|
||||
async def test_tts_cache() -> None:
|
||||
"""Test TTSCache."""
|
||||
|
||||
async def data_gen(queue: asyncio.Queue[bytes | None | Exception]):
|
||||
async def data_gen(queue: asyncio.Queue[bytes | Exception | None]):
|
||||
while chunk := await queue.get():
|
||||
if isinstance(chunk, Exception):
|
||||
raise chunk
|
||||
|
||||
@@ -3243,7 +3243,7 @@ async def _setup_numerical_condition(
|
||||
condition_options: dict[str, Any],
|
||||
target_config: dict[str, Any],
|
||||
domain_specs: Mapping[str, DomainSpec] | None = None,
|
||||
valid_unit: str | None | UndefinedType = UNDEFINED,
|
||||
valid_unit: str | UndefinedType | None = UNDEFINED,
|
||||
primary_entities_only: bool = True,
|
||||
) -> condition.ConditionChecker:
|
||||
"""Set up a numerical condition via a mock platform and return the test."""
|
||||
@@ -3506,7 +3506,7 @@ async def test_numerical_condition_attribute_value_source_skips_unit_check(
|
||||
)
|
||||
async def test_numerical_condition_valid_unit(
|
||||
hass: HomeAssistant,
|
||||
valid_unit: str | None | UndefinedType,
|
||||
valid_unit: str | UndefinedType | None,
|
||||
entity_unit: str | None,
|
||||
expected: bool,
|
||||
) -> None:
|
||||
|
||||
@@ -1044,7 +1044,7 @@ async def test_friendly_name_attr(
|
||||
hass: HomeAssistant,
|
||||
has_entity_name: bool,
|
||||
entity_name: str | None,
|
||||
device_name: str | None | UndefinedType,
|
||||
device_name: str | UndefinedType | None,
|
||||
expected_friendly_name: str | None,
|
||||
) -> None:
|
||||
"""Test friendly name when the entity uses _attr_*."""
|
||||
|
||||
Reference in New Issue
Block a user