mirror of
https://github.com/home-assistant/core.git
synced 2025-04-29 11:47:50 +00:00
Postponed evaluation of annotations for integrations (#46455)
This commit is contained in:
parent
061d9c5293
commit
dd8d4471ec
@ -1,4 +1,6 @@
|
|||||||
"""Reads vehicle status from BMW connected drive portal."""
|
"""Reads vehicle status from BMW connected drive portal."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ async def update_listener(hass, config_entry):
|
|||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
def setup_account(entry: ConfigEntry, hass, name: str) -> "BMWConnectedDriveAccount":
|
def setup_account(entry: ConfigEntry, hass, name: str) -> BMWConnectedDriveAccount:
|
||||||
"""Set up a new BMWConnectedDriveAccount based on the config."""
|
"""Set up a new BMWConnectedDriveAccount based on the config."""
|
||||||
username = entry.data[CONF_USERNAME]
|
username = entry.data[CONF_USERNAME]
|
||||||
password = entry.data[CONF_PASSWORD]
|
password = entry.data[CONF_PASSWORD]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Helpers to deal with Cast devices."""
|
"""Helpers to deal with Cast devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
@ -57,7 +59,7 @@ class ChromecastInfo:
|
|||||||
return None
|
return None
|
||||||
return CAST_MANUFACTURERS.get(self.model_name.lower(), "Google Inc.")
|
return CAST_MANUFACTURERS.get(self.model_name.lower(), "Google Inc.")
|
||||||
|
|
||||||
def fill_out_missing_chromecast_info(self) -> "ChromecastInfo":
|
def fill_out_missing_chromecast_info(self) -> ChromecastInfo:
|
||||||
"""Return a new ChromecastInfo object with missing attributes filled in.
|
"""Return a new ChromecastInfo object with missing attributes filled in.
|
||||||
|
|
||||||
Uses blocking HTTP / HTTPS.
|
Uses blocking HTTP / HTTPS.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Component to count within automations."""
|
"""Component to count within automations."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
@ -179,7 +181,7 @@ class Counter(RestoreEntity):
|
|||||||
self.editable: bool = True
|
self.editable: bool = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: Dict) -> "Counter":
|
def from_yaml(cls, config: Dict) -> Counter:
|
||||||
"""Create counter instance from yaml config."""
|
"""Create counter instance from yaml config."""
|
||||||
counter = cls(config)
|
counter = cls(config)
|
||||||
counter.editable = False
|
counter.editable = False
|
||||||
|
@ -78,11 +78,11 @@ class EsphomeTextSensor(EsphomeEntity):
|
|||||||
"""A text sensor implementation for ESPHome."""
|
"""A text sensor implementation for ESPHome."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _static_info(self) -> "TextSensorInfo":
|
def _static_info(self) -> TextSensorInfo:
|
||||||
return super()._static_info
|
return super()._static_info
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _state(self) -> Optional["TextSensorState"]:
|
def _state(self) -> Optional[TextSensorState]:
|
||||||
return super()._state
|
return super()._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Config flow for the Huawei LTE platform."""
|
"""Config flow for the Huawei LTE platform."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import logging
|
import logging
|
||||||
@ -48,7 +49,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: config_entries.ConfigEntry,
|
config_entry: config_entries.ConfigEntry,
|
||||||
) -> "OptionsFlowHandler":
|
) -> OptionsFlowHandler:
|
||||||
"""Get options flow."""
|
"""Get options flow."""
|
||||||
return OptionsFlowHandler(config_entry)
|
return OptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Support for Huawei LTE router notifications."""
|
"""Support for Huawei LTE router notifications."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
@ -21,7 +22,7 @@ async def async_get_service(
|
|||||||
hass: HomeAssistantType,
|
hass: HomeAssistantType,
|
||||||
config: Dict[str, Any],
|
config: Dict[str, Any],
|
||||||
discovery_info: Optional[Dict[str, Any]] = None,
|
discovery_info: Optional[Dict[str, Any]] = None,
|
||||||
) -> Optional["HuaweiLteSmsNotificationService"]:
|
) -> Optional[HuaweiLteSmsNotificationService]:
|
||||||
"""Get the notification service."""
|
"""Get the notification service."""
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return None
|
return None
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support to keep track of user controlled booleans for within automation."""
|
"""Support to keep track of user controlled booleans for within automation."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -150,7 +152,7 @@ class InputBoolean(ToggleEntity, RestoreEntity):
|
|||||||
self._state = config.get(CONF_INITIAL)
|
self._state = config.get(CONF_INITIAL)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: typing.Dict) -> "InputBoolean":
|
def from_yaml(cls, config: typing.Dict) -> InputBoolean:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
input_bool = cls(config)
|
input_bool = cls(config)
|
||||||
input_bool.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
input_bool.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support to select a date and/or a time."""
|
"""Support to select a date and/or a time."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime as py_datetime
|
import datetime as py_datetime
|
||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
@ -228,7 +230,7 @@ class InputDatetime(RestoreEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: typing.Dict) -> "InputDatetime":
|
def from_yaml(cls, config: typing.Dict) -> InputDatetime:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
input_dt = cls(config)
|
input_dt = cls(config)
|
||||||
input_dt.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
input_dt.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support to set a numeric value from a slider or text box."""
|
"""Support to set a numeric value from a slider or text box."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -202,7 +204,7 @@ class InputNumber(RestoreEntity):
|
|||||||
self._current_value = config.get(CONF_INITIAL)
|
self._current_value = config.get(CONF_INITIAL)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: typing.Dict) -> "InputNumber":
|
def from_yaml(cls, config: typing.Dict) -> InputNumber:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
input_num = cls(config)
|
input_num = cls(config)
|
||||||
input_num.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
input_num.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support to select an option from a list."""
|
"""Support to select an option from a list."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -207,7 +209,7 @@ class InputSelect(RestoreEntity):
|
|||||||
self._current_option = config.get(CONF_INITIAL)
|
self._current_option = config.get(CONF_INITIAL)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: typing.Dict) -> "InputSelect":
|
def from_yaml(cls, config: typing.Dict) -> InputSelect:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
input_select = cls(config)
|
input_select = cls(config)
|
||||||
input_select.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
input_select.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support to enter a value into a text box."""
|
"""Support to enter a value into a text box."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
@ -196,7 +198,7 @@ class InputText(RestoreEntity):
|
|||||||
self._current_value = config.get(CONF_INITIAL)
|
self._current_value = config.get(CONF_INITIAL)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: typing.Dict) -> "InputText":
|
def from_yaml(cls, config: typing.Dict) -> InputText:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
input_text = cls(config)
|
input_text = cls(config)
|
||||||
input_text.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
input_text.entity_id = f"{DOMAIN}.{config[CONF_ID]}"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Provides functionality to interact with lights."""
|
"""Provides functionality to interact with lights."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@ -327,7 +329,7 @@ class Profile:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_csv_row(cls, csv_row: List[str]) -> "Profile":
|
def from_csv_row(cls, csv_row: List[str]) -> Profile:
|
||||||
"""Create profile from a CSV row tuple."""
|
"""Create profile from a CSV row tuple."""
|
||||||
return cls(*cls.SCHEMA(csv_row))
|
return cls(*cls.SCHEMA(csv_row))
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Component to interface with various media players."""
|
"""Component to interface with various media players."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import collections
|
import collections
|
||||||
@ -851,7 +853,7 @@ class MediaPlayerEntity(Entity):
|
|||||||
self,
|
self,
|
||||||
media_content_type: Optional[str] = None,
|
media_content_type: Optional[str] = None,
|
||||||
media_content_id: Optional[str] = None,
|
media_content_id: Optional[str] = None,
|
||||||
) -> "BrowseMedia":
|
) -> BrowseMedia:
|
||||||
"""Return a BrowseMedia instance.
|
"""Return a BrowseMedia instance.
|
||||||
|
|
||||||
The BrowseMedia instance will be used by the
|
The BrowseMedia instance will be used by the
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Media Source models."""
|
"""Media Source models."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
@ -82,12 +84,12 @@ class MediaSourceItem:
|
|||||||
return await self.async_media_source().async_resolve_media(self)
|
return await self.async_media_source().async_resolve_media(self)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_media_source(self) -> "MediaSource":
|
def async_media_source(self) -> MediaSource:
|
||||||
"""Return media source that owns this item."""
|
"""Return media source that owns this item."""
|
||||||
return self.hass.data[DOMAIN][self.domain]
|
return self.hass.data[DOMAIN][self.domain]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_uri(cls, hass: HomeAssistant, uri: str) -> "MediaSourceItem":
|
def from_uri(cls, hass: HomeAssistant, uri: str) -> MediaSourceItem:
|
||||||
"""Create an item from a uri."""
|
"""Create an item from a uri."""
|
||||||
match = URI_SCHEME_REGEX.match(uri)
|
match = URI_SCHEME_REGEX.match(uri)
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for Timers."""
|
"""Support for Timers."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
@ -198,7 +200,7 @@ class Timer(RestoreEntity):
|
|||||||
self._listener = None
|
self._listener = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: Dict) -> "Timer":
|
def from_yaml(cls, config: Dict) -> Timer:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
timer = cls(config)
|
timer = cls(config)
|
||||||
timer.entity_id = ENTITY_ID_FORMAT.format(config[CONF_ID])
|
timer.entity_id = ENTITY_ID_FORMAT.format(config[CONF_ID])
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for the Transmission BitTorrent client API."""
|
"""Support for the Transmission BitTorrent client API."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
@ -176,7 +178,7 @@ class TransmissionClient:
|
|||||||
self.unsub_timer = None
|
self.unsub_timer = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def api(self) -> "TransmissionData":
|
def api(self) -> TransmissionData:
|
||||||
"""Return the TransmissionData object."""
|
"""Return the TransmissionData object."""
|
||||||
return self._tm_data
|
return self._tm_data
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Channels module for Zigbee Home Automation."""
|
"""Channels module for Zigbee Home Automation."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ class Channels:
|
|||||||
self._zha_device = zha_device
|
self._zha_device = zha_device
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pools(self) -> List["ChannelPool"]:
|
def pools(self) -> List[ChannelPool]:
|
||||||
"""Return channel pools list."""
|
"""Return channel pools list."""
|
||||||
return self._pools
|
return self._pools
|
||||||
|
|
||||||
@ -102,7 +104,7 @@ class Channels:
|
|||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls, zha_device: zha_typing.ZhaDeviceType) -> "Channels":
|
def new(cls, zha_device: zha_typing.ZhaDeviceType) -> Channels:
|
||||||
"""Create new instance."""
|
"""Create new instance."""
|
||||||
channels = cls(zha_device)
|
channels = cls(zha_device)
|
||||||
for ep_id in sorted(zha_device.device.endpoints):
|
for ep_id in sorted(zha_device.device.endpoints):
|
||||||
@ -263,7 +265,7 @@ class ChannelPool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new(cls, channels: Channels, ep_id: int) -> "ChannelPool":
|
def new(cls, channels: Channels, ep_id: int) -> ChannelPool:
|
||||||
"""Create new channels for an endpoint."""
|
"""Create new channels for an endpoint."""
|
||||||
pool = cls(channels, ep_id)
|
pool = cls(channels, ep_id)
|
||||||
pool.add_all_channels()
|
pool.add_all_channels()
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for the definition of zones."""
|
"""Support for the definition of zones."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Optional, cast
|
from typing import Any, Dict, Optional, cast
|
||||||
|
|
||||||
@ -285,7 +287,7 @@ class Zone(entity.Entity):
|
|||||||
self._generate_attrs()
|
self._generate_attrs()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, config: Dict) -> "Zone":
|
def from_yaml(cls, config: Dict) -> Zone:
|
||||||
"""Return entity instance initialized from yaml storage."""
|
"""Return entity instance initialized from yaml storage."""
|
||||||
zone = cls(config)
|
zone = cls(config)
|
||||||
zone.editable = False
|
zone.editable = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user