2022-01-24 13:38:56 +01:00
|
|
|
"""Plugin to enforce type hints on specific functions."""
|
2024-03-08 16:36:11 +01:00
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from dataclasses import dataclass
|
2022-08-01 19:34:06 +02:00
|
|
|
from enum import Enum
|
2022-01-24 13:38:56 +01:00
|
|
|
import re
|
2022-09-07 09:44:15 +02:00
|
|
|
from typing import TYPE_CHECKING
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2022-06-02 07:48:59 +02:00
|
|
|
from astroid import nodes
|
2022-09-07 09:44:15 +02:00
|
|
|
from astroid.exceptions import NameInferenceError
|
2022-01-24 13:38:56 +01:00
|
|
|
from pylint.checkers import BaseChecker
|
|
|
|
from pylint.lint import PyLinter
|
|
|
|
|
2022-01-24 18:51:06 +01:00
|
|
|
from homeassistant.const import Platform
|
2022-02-06 18:36:02 +01:00
|
|
|
|
2022-09-07 09:44:15 +02:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
# InferenceResult is available only from astroid >= 2.12.0
|
|
|
|
# pre-commit should still work on out of date environments
|
|
|
|
from astroid.typing import InferenceResult
|
|
|
|
|
2023-02-04 18:52:59 +01:00
|
|
|
_COMMON_ARGUMENTS: dict[str, list[str]] = {
|
|
|
|
"hass": ["HomeAssistant", "HomeAssistant | None"]
|
|
|
|
}
|
|
|
|
_PLATFORMS: set[str] = {platform.value for platform in Platform}
|
2024-04-30 11:29:43 +02:00
|
|
|
_KNOWN_GENERIC_TYPES: set[str] = {
|
|
|
|
"ConfigEntry",
|
|
|
|
}
|
|
|
|
_KNOWN_GENERIC_TYPES_TUPLE = tuple(_KNOWN_GENERIC_TYPES)
|
2023-02-04 18:52:59 +01:00
|
|
|
|
2022-08-01 19:34:06 +02:00
|
|
|
|
|
|
|
class _Special(Enum):
|
2023-01-16 20:53:14 +01:00
|
|
|
"""Sentinel values."""
|
2022-08-01 19:34:06 +02:00
|
|
|
|
|
|
|
UNDEFINED = 1
|
|
|
|
|
2022-01-24 18:51:06 +01:00
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
@dataclass
|
|
|
|
class TypeHintMatch:
|
|
|
|
"""Class for pattern matching."""
|
|
|
|
|
|
|
|
function_name: str
|
2022-08-01 19:34:06 +02:00
|
|
|
return_type: list[str | _Special | None] | str | _Special | None
|
2022-06-21 14:36:22 +02:00
|
|
|
arg_types: dict[int, str] | None = None
|
2022-06-22 12:48:23 +02:00
|
|
|
"""arg_types is for positional arguments"""
|
|
|
|
named_arg_types: dict[str, str] | None = None
|
|
|
|
"""named_arg_types is for named or keyword arguments"""
|
2022-06-21 18:53:31 +02:00
|
|
|
kwargs_type: str | None = None
|
2022-06-22 12:48:23 +02:00
|
|
|
"""kwargs_type is for the special case `**kwargs`"""
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart: bool = False
|
|
|
|
|
|
|
|
def need_to_check_function(self, node: nodes.FunctionDef) -> bool:
|
|
|
|
"""Confirm if function should be checked."""
|
|
|
|
return (
|
|
|
|
self.function_name == node.name
|
|
|
|
or self.has_async_counterpart
|
|
|
|
and node.name == f"async_{self.function_name}"
|
2022-06-28 10:08:36 +02:00
|
|
|
or self.function_name.endswith("*")
|
|
|
|
and node.name.startswith(self.function_name[:-1])
|
2022-06-22 23:51:40 +02:00
|
|
|
)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
|
|
|
|
2024-02-29 16:52:39 +01:00
|
|
|
@dataclass(kw_only=True)
|
2022-06-01 13:09:53 +02:00
|
|
|
class ClassTypeHintMatch:
|
|
|
|
"""Class for pattern matching."""
|
|
|
|
|
|
|
|
base_class: str
|
2024-02-29 16:52:39 +01:00
|
|
|
exclude_base_classes: set[str] | None = None
|
2022-06-01 13:09:53 +02:00
|
|
|
matches: list[TypeHintMatch]
|
|
|
|
|
|
|
|
|
2022-08-18 19:22:08 +02:00
|
|
|
_INNER_MATCH = r"((?:[\w\| ]+)|(?:\.{3})|(?:\w+\[.+\]))"
|
2022-05-31 11:20:31 +02:00
|
|
|
_TYPE_HINT_MATCHERS: dict[str, re.Pattern[str]] = {
|
2022-01-25 18:21:59 +01:00
|
|
|
# a_or_b matches items such as "DiscoveryInfoType | None"
|
2022-08-18 19:22:08 +02:00
|
|
|
# or "dict | list | None"
|
|
|
|
"a_or_b": re.compile(rf"^(.+) \| {_INNER_MATCH}$"),
|
2022-01-25 18:21:59 +01:00
|
|
|
}
|
2022-07-10 00:31:09 +02:00
|
|
|
_INNER_MATCH_POSSIBILITIES = [i + 1 for i in range(5)]
|
|
|
|
_TYPE_HINT_MATCHERS.update(
|
|
|
|
{
|
|
|
|
f"x_of_y_{i}": re.compile(
|
|
|
|
rf"^(\w+)\[{_INNER_MATCH}" + f", {_INNER_MATCH}" * (i - 1) + r"\]$"
|
|
|
|
)
|
|
|
|
for i in _INNER_MATCH_POSSIBILITIES
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-01-25 18:21:59 +01:00
|
|
|
|
2022-05-31 11:20:31 +02:00
|
|
|
_MODULE_REGEX: re.Pattern[str] = re.compile(r"^homeassistant\.components\.\w+(\.\w+)?$")
|
|
|
|
|
2023-02-06 16:25:12 +01:00
|
|
|
_METHOD_MATCH: list[TypeHintMatch] = [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="__init__",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2023-02-07 10:21:54 +01:00
|
|
|
_TEST_FIXTURES: dict[str, list[str] | str] = {
|
2023-02-08 10:51:09 +01:00
|
|
|
"aioclient_mock": "AiohttpClientMocker",
|
|
|
|
"aiohttp_client": "ClientSessionGenerator",
|
2023-02-08 16:28:44 +01:00
|
|
|
"area_registry": "AreaRegistry",
|
2023-02-10 11:11:39 +01:00
|
|
|
"async_setup_recorder_instance": "RecorderInstanceGenerator",
|
2023-02-07 11:34:02 +01:00
|
|
|
"caplog": "pytest.LogCaptureFixture",
|
2023-02-11 13:48:53 +01:00
|
|
|
"current_request_with_host": "None",
|
2023-02-08 16:28:44 +01:00
|
|
|
"device_registry": "DeviceRegistry",
|
2023-02-11 13:48:53 +01:00
|
|
|
"enable_bluetooth": "None",
|
|
|
|
"enable_custom_integrations": "None",
|
2023-02-10 11:11:39 +01:00
|
|
|
"enable_nightly_purge": "bool",
|
|
|
|
"enable_statistics": "bool",
|
2023-03-22 21:05:23 +01:00
|
|
|
"enable_schema_validation": "bool",
|
2023-02-08 16:28:44 +01:00
|
|
|
"entity_registry": "EntityRegistry",
|
2023-03-26 15:21:19 +02:00
|
|
|
"entity_registry_enabled_by_default": "None",
|
2023-03-17 03:39:41 +01:00
|
|
|
"freezer": "FrozenDateTimeFactory",
|
2023-02-11 13:48:53 +01:00
|
|
|
"hass_access_token": "str",
|
|
|
|
"hass_admin_credential": "Credentials",
|
|
|
|
"hass_admin_user": "MockUser",
|
2023-02-08 10:51:09 +01:00
|
|
|
"hass_client": "ClientSessionGenerator",
|
|
|
|
"hass_client_no_auth": "ClientSessionGenerator",
|
2023-02-21 08:48:44 +01:00
|
|
|
"hass_config": "ConfigType",
|
2023-02-22 17:18:11 +01:00
|
|
|
"hass_config_yaml": "str",
|
|
|
|
"hass_config_yaml_files": "dict[str, str]",
|
2023-02-11 13:48:53 +01:00
|
|
|
"hass_owner_user": "MockUser",
|
|
|
|
"hass_read_only_access_token": "str",
|
|
|
|
"hass_read_only_user": "MockUser",
|
2023-02-10 11:11:39 +01:00
|
|
|
"hass_recorder": "Callable[..., HomeAssistant]",
|
2023-02-13 12:12:34 +01:00
|
|
|
"hass_storage": "dict[str, Any]",
|
2023-02-11 13:48:53 +01:00
|
|
|
"hass_supervisor_access_token": "str",
|
|
|
|
"hass_supervisor_user": "MockUser",
|
2023-02-08 10:51:09 +01:00
|
|
|
"hass_ws_client": "WebSocketGenerator",
|
2023-02-08 16:28:44 +01:00
|
|
|
"issue_registry": "IssueRegistry",
|
2023-02-11 13:48:53 +01:00
|
|
|
"legacy_auth": "LegacyApiPasswordAuthProvider",
|
|
|
|
"local_auth": "HassAuthProvider",
|
|
|
|
"mock_async_zeroconf": "None",
|
|
|
|
"mock_bleak_scanner_start": "MagicMock",
|
|
|
|
"mock_bluetooth": "None",
|
|
|
|
"mock_bluetooth_adapters": "None",
|
|
|
|
"mock_device_tracker_conf": "list[Device]",
|
|
|
|
"mock_get_source_ip": "None",
|
2023-02-20 16:57:12 +01:00
|
|
|
"mock_hass_config": "None",
|
|
|
|
"mock_hass_config_yaml": "None",
|
2023-02-11 13:48:53 +01:00
|
|
|
"mock_zeroconf": "None",
|
2023-02-07 10:21:54 +01:00
|
|
|
"mqtt_client_mock": "MqttMockPahoClient",
|
|
|
|
"mqtt_mock": "MqttMockHAClient",
|
2023-04-12 09:43:03 +02:00
|
|
|
"mqtt_mock_entry": "MqttMockHAClientGenerator",
|
2023-02-10 11:11:39 +01:00
|
|
|
"recorder_db_url": "str",
|
|
|
|
"recorder_mock": "Recorder",
|
2023-02-10 11:44:09 +01:00
|
|
|
"requests_mock": "requests_mock.Mocker",
|
2023-02-17 22:35:55 +01:00
|
|
|
"snapshot": "SnapshotAssertion",
|
2023-05-26 08:13:13 +02:00
|
|
|
"stub_blueprint_populate": "None",
|
2023-02-11 13:48:53 +01:00
|
|
|
"tmp_path": "Path",
|
2023-03-17 10:22:02 +01:00
|
|
|
"tmpdir": "py.path.local",
|
2023-02-07 10:21:54 +01:00
|
|
|
}
|
|
|
|
_TEST_FUNCTION_MATCH = TypeHintMatch(
|
|
|
|
function_name="test_*",
|
|
|
|
return_type=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-05-31 11:20:31 +02:00
|
|
|
_FUNCTION_MATCH: dict[str, list[TypeHintMatch]] = {
|
|
|
|
"__init__": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="setup",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-05-31 11:20:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_setup_entry",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_remove_entry",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_unload_entry",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_migrate_entry",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
2022-06-01 08:38:48 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_remove_config_entry_device",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
2: "DeviceEntry",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
2023-03-31 20:19:58 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_reset_platform",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
2022-05-31 11:20:31 +02:00
|
|
|
],
|
|
|
|
"__any_platform__": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="setup_platform",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
2: "AddEntitiesCallback",
|
|
|
|
3: "DiscoveryInfoType | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-05-31 11:20:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_setup_entry",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
2: "AddEntitiesCallback",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"application_credentials": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_auth_implementation",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
2: "ClientCredential",
|
|
|
|
},
|
|
|
|
return_type="AbstractOAuth2Implementation",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_authorization_server",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
},
|
|
|
|
return_type="AuthorizationServer",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"backup": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_pre_backup",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_post_backup",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"cast": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_media_browser_root_object",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type="list[BrowseMedia]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_browse_media",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
2022-09-09 08:57:14 +02:00
|
|
|
1: "MediaType | str",
|
2022-05-31 11:20:31 +02:00
|
|
|
2: "str",
|
|
|
|
3: "str",
|
|
|
|
},
|
|
|
|
return_type=["BrowseMedia", "BrowseMedia | None"],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_play_media",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
2: "Chromecast",
|
2022-09-09 08:57:14 +02:00
|
|
|
3: "MediaType | str",
|
2022-05-31 11:20:31 +02:00
|
|
|
4: "str",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"config_flow": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="_async_has_devices",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"device_action": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_validate_action_config",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="ConfigType",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_call_action_from_config",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
2: "TemplateVarsType",
|
|
|
|
3: "Context | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_action_capabilities",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="dict[str, Schema]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_actions",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=["list[dict[str, str]]", "list[dict[str, Any]]"],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"device_condition": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_validate_condition_config",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="ConfigType",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_condition_from_config",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="ConditionCheckerType",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_condition_capabilities",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="dict[str, Schema]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_conditions",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=["list[dict[str, str]]", "list[dict[str, Any]]"],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"device_tracker": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="setup_scanner",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
2022-07-29 00:27:47 +02:00
|
|
|
2: "SeeCallback",
|
2022-05-31 11:20:31 +02:00
|
|
|
3: "DiscoveryInfoType | None",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_setup_scanner",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
2022-07-29 00:27:47 +02:00
|
|
|
2: "AsyncSeeCallback",
|
2022-05-31 11:20:31 +02:00
|
|
|
3: "DiscoveryInfoType | None",
|
|
|
|
},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="get_scanner",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
2022-09-07 10:58:54 +02:00
|
|
|
return_type=["DeviceScanner", None],
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-05-31 11:20:31 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
"device_trigger": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_validate_condition_config",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="ConfigType",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_attach_trigger",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
2022-08-16 11:16:33 +02:00
|
|
|
2: "TriggerActionType",
|
|
|
|
3: "TriggerInfo",
|
2022-05-31 11:20:31 +02:00
|
|
|
},
|
|
|
|
return_type="CALLBACK_TYPE",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_trigger_capabilities",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
},
|
|
|
|
return_type="dict[str, Schema]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_triggers",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=["list[dict[str, str]]", "list[dict[str, Any]]"],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
"diagnostics": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_config_entry_diagnostics",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
},
|
2023-01-13 09:17:54 +01:00
|
|
|
return_type="Mapping[str, Any]",
|
2022-05-31 11:20:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_device_diagnostics",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigEntry",
|
|
|
|
2: "DeviceEntry",
|
|
|
|
},
|
2023-01-13 09:17:54 +01:00
|
|
|
return_type="Mapping[str, Any]",
|
2022-05-31 11:20:31 +02:00
|
|
|
),
|
|
|
|
],
|
2022-09-06 12:18:15 +02:00
|
|
|
"notify": [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="get_service",
|
|
|
|
arg_types={
|
|
|
|
0: "HomeAssistant",
|
|
|
|
1: "ConfigType",
|
|
|
|
2: "DiscoveryInfoType | None",
|
|
|
|
},
|
2022-09-07 09:44:15 +02:00
|
|
|
return_type=["BaseNotificationService", None],
|
2022-09-06 12:18:15 +02:00
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
2022-01-24 13:38:56 +01:00
|
|
|
}
|
|
|
|
|
2022-06-01 13:09:53 +02:00
|
|
|
_CLASS_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
|
|
|
"config_flow": [
|
2022-06-28 10:08:36 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="FlowHandler",
|
2024-02-29 16:52:39 +01:00
|
|
|
exclude_base_classes={"ConfigEntryBaseFlow"},
|
2022-06-28 10:08:36 +02:00
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_*",
|
|
|
|
arg_types={},
|
|
|
|
return_type="FlowResult",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-06-01 13:09:53 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ConfigFlow",
|
|
|
|
matches=[
|
2022-06-13 11:14:30 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_options_flow",
|
|
|
|
arg_types={
|
|
|
|
0: "ConfigEntry",
|
|
|
|
},
|
|
|
|
return_type="OptionsFlow",
|
|
|
|
),
|
2022-06-01 13:09:53 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_dhcp",
|
|
|
|
arg_types={
|
|
|
|
1: "DhcpServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_hassio",
|
|
|
|
arg_types={
|
|
|
|
1: "HassioServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_homekit",
|
|
|
|
arg_types={
|
|
|
|
1: "ZeroconfServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_mqtt",
|
|
|
|
arg_types={
|
|
|
|
1: "MqttServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
2022-06-28 10:52:41 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_reauth",
|
|
|
|
arg_types={
|
|
|
|
1: "Mapping[str, Any]",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-28 10:52:41 +02:00
|
|
|
),
|
2022-06-01 13:09:53 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_ssdp",
|
|
|
|
arg_types={
|
|
|
|
1: "SsdpServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_usb",
|
|
|
|
arg_types={
|
|
|
|
1: "UsbServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_zeroconf",
|
|
|
|
arg_types={
|
|
|
|
1: "ZeroconfServiceInfo",
|
|
|
|
},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_*",
|
|
|
|
arg_types={},
|
|
|
|
return_type="ConfigFlowResult",
|
2024-02-29 16:52:39 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="OptionsFlow",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_step_*",
|
|
|
|
arg_types={},
|
2024-03-01 13:07:13 +01:00
|
|
|
return_type="ConfigFlowResult",
|
2022-06-01 13:09:53 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-06-21 14:36:22 +02:00
|
|
|
],
|
|
|
|
}
|
2022-06-21 18:53:31 +02:00
|
|
|
# Overriding properties and functions are normally checked by mypy, and will only
|
|
|
|
# be checked by pylint when --ignore-missing-annotations is False
|
2022-08-02 00:03:52 +02:00
|
|
|
|
2022-06-27 12:10:31 +02:00
|
|
|
_ENTITY_MATCH: list[TypeHintMatch] = [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="should_poll",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="unique_id",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="name",
|
2023-06-15 11:09:53 +02:00
|
|
|
return_type=["str", "UndefinedType", None],
|
2022-06-27 12:10:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state",
|
|
|
|
return_type=["StateType", None, "str", "int", "float"],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="capability_attributes",
|
|
|
|
return_type=["Mapping[str, Any]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state_attributes",
|
|
|
|
return_type=["dict[str, Any]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="extra_state_attributes",
|
|
|
|
return_type=["Mapping[str, Any]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_info",
|
|
|
|
return_type=["DeviceInfo", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-08-02 00:03:52 +02:00
|
|
|
return_type=["str", None],
|
2022-06-27 12:10:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="unit_of_measurement",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="icon",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="entity_picture",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="available",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="assumed_state",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="force_update",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="entity_registry_enabled_default",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="entity_registry_visible_default",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="attribution",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="entity_category",
|
|
|
|
return_type=["EntityCategory", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_removed_from_registry",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_added_to_hass",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_will_remove_from_hass",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_registry_entry_updated",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="update",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
]
|
2022-08-17 16:58:42 +02:00
|
|
|
_RESTORE_ENTITY_MATCH: list[TypeHintMatch] = [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_last_state",
|
|
|
|
return_type=["State", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_last_extra_data",
|
|
|
|
return_type=["ExtraStoredData", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="extra_restore_state_data",
|
|
|
|
return_type=["ExtraStoredData", None],
|
|
|
|
),
|
|
|
|
]
|
2022-06-23 21:31:30 +02:00
|
|
|
_TOGGLE_ENTITY_MATCH: list[TypeHintMatch] = [
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_on",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_off",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="toggle",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
]
|
2022-06-21 18:53:31 +02:00
|
|
|
_INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
|
2022-06-30 19:00:34 +02:00
|
|
|
# "air_quality": [], # ignored as deprecated
|
2022-06-28 10:02:57 +02:00
|
|
|
"alarm_control_panel": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-28 10:02:57 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="AlarmControlPanelEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="code_format",
|
|
|
|
return_type=["CodeFormat", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="changed_by",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="code_arm_required",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-21 22:58:36 +01:00
|
|
|
return_type="AlarmControlPanelEntityFeature",
|
2022-06-28 10:02:57 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_disarm",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_arm_home",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_arm_away",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_arm_night",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_arm_vacation",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_trigger",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="alarm_arm_custom_bypass",
|
|
|
|
named_arg_types={
|
|
|
|
"code": "str | None",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-29 11:41:56 +02:00
|
|
|
"binary_sensor": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-29 11:41:56 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="BinarySensorEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:52:26 +01:00
|
|
|
return_type=["BinarySensorDeviceClass", None],
|
2022-06-29 11:41:56 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_on",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-29 12:36:57 +02:00
|
|
|
"button": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-17 18:42:35 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-29 12:36:57 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ButtonEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
|
|
|
return_type=["ButtonDeviceClass", "str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="press",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-30 19:00:34 +02:00
|
|
|
"calendar": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-30 19:00:34 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="CalendarEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="event",
|
|
|
|
return_type=["CalendarEvent", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_events",
|
|
|
|
arg_types={
|
|
|
|
1: "HomeAssistant",
|
|
|
|
2: "datetime",
|
|
|
|
3: "datetime",
|
|
|
|
},
|
|
|
|
return_type="list[CalendarEvent]",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-30 21:50:57 +02:00
|
|
|
"camera": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-30 21:50:57 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Camera",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="entity_picture",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:08:28 +01:00
|
|
|
return_type="CameraEntityFeature",
|
2022-06-30 21:50:57 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_recording",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_streaming",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="brand",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="motion_detection_enabled",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="model",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="frame_interval",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="frontend_stream_type",
|
|
|
|
return_type=["StreamType", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="available",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_create_stream",
|
|
|
|
return_type=["Stream", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="stream_source",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_handle_web_rtc_offer",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="camera_image",
|
|
|
|
named_arg_types={
|
|
|
|
"width": "int | None",
|
|
|
|
"height": "int | None",
|
|
|
|
},
|
|
|
|
return_type=["bytes", None],
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="handle_async_still_stream",
|
|
|
|
arg_types={
|
|
|
|
1: "Request",
|
|
|
|
2: "float",
|
|
|
|
},
|
|
|
|
return_type="StreamResponse",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="handle_async_mjpeg_stream",
|
|
|
|
arg_types={
|
|
|
|
1: "Request",
|
|
|
|
},
|
|
|
|
return_type=["StreamResponse", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_on",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_off",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="enable_motion_detection",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="disable_motion_detection",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-30 23:49:23 +02:00
|
|
|
"climate": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-30 23:49:23 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ClimateEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="precision",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="temperature_unit",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type=["float", None],
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type=["float", None],
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="hvac_mode",
|
2023-06-15 20:16:17 +02:00
|
|
|
return_type=["HVACMode", None],
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="hvac_modes",
|
2023-06-15 20:16:17 +02:00
|
|
|
return_type="list[HVACMode]",
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="hvac_action",
|
2023-06-15 20:16:17 +02:00
|
|
|
return_type=["HVACAction", None],
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_temperature",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature_step",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature_high",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature_low",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="preset_mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="preset_modes",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_aux_heat",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="fan_mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="fan_modes",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="swing_mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="swing_modes",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_temperature",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_humidity",
|
|
|
|
arg_types={
|
|
|
|
1: "int",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_fan_mode",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_hvac_mode",
|
|
|
|
arg_types={
|
|
|
|
1: "HVACMode",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_swing_mode",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_preset_mode",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_aux_heat_on",
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_aux_heat_off",
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_off",
|
|
|
|
return_type="None",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:08:53 +01:00
|
|
|
return_type="ClimateEntityFeature",
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="min_temp",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="max_temp",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="min_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type="float",
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="max_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type="float",
|
2022-06-30 23:49:23 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-27 14:58:23 +02:00
|
|
|
"cover": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-27 14:58:23 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="CoverEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 16:13:29 +01:00
|
|
|
return_type=["CoverDeviceClass", None],
|
2022-06-27 14:58:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_cover_position",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_cover_tilt_position",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_opening",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_closing",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_closed",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
2022-11-17 08:39:44 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:09:19 +01:00
|
|
|
return_type="CoverEntityFeature",
|
2022-11-17 08:39:44 +01:00
|
|
|
),
|
2022-06-27 14:58:23 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="open_cover",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="close_cover",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="toggle",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_cover_position",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="stop_cover",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="open_cover_tilt",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="close_cover_tilt",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_cover_tilt_position",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="stop_cover_tilt",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="toggle_tilt",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-04 21:03:13 +02:00
|
|
|
"device_tracker": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-04 21:03:13 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="BaseTrackerEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="battery_level",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="source_type",
|
|
|
|
return_type=["SourceType", "str"],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="TrackerEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="force_update",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="location_accuracy",
|
|
|
|
return_type="int",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="location_name",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="latitude",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="longitude",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ScannerEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="ip_address",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="mac_address",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="hostname",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_connected",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-22 12:48:23 +02:00
|
|
|
"fan": [
|
2022-06-27 12:10:31 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-23 21:31:30 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-22 12:48:23 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="FanEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="percentage",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="speed_count",
|
|
|
|
return_type="int",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="percentage_step",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_direction",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="oscillating",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="preset_mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="preset_modes",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
2022-11-17 10:30:39 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:13:54 +01:00
|
|
|
return_type="FanEntityFeature",
|
2022-11-17 10:30:39 +01:00
|
|
|
),
|
2022-06-22 12:48:23 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_percentage",
|
|
|
|
arg_types={1: "int"},
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-22 12:48:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_preset_mode",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-22 12:48:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_direction",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-22 12:48:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
named_arg_types={
|
|
|
|
"percentage": "int | None",
|
|
|
|
"preset_mode": "str | None",
|
|
|
|
},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-22 12:48:23 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="oscillate",
|
|
|
|
arg_types={1: "bool"},
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-22 12:48:23 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-07-05 12:27:00 +02:00
|
|
|
"geo_location": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-07-05 12:27:00 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="GeolocationEvent",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="source",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="distance",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="latitude",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="longitude",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-09-13 14:39:39 +02:00
|
|
|
"image_processing": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-09-13 14:39:39 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ImageProcessingEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="camera_entity",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="confidence",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
2022-12-06 16:35:40 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
|
|
|
return_type=["ImageProcessingDeviceClass", None],
|
|
|
|
),
|
2022-09-13 14:39:39 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="process_image",
|
2022-09-14 11:13:48 +02:00
|
|
|
arg_types={1: "bytes"},
|
2022-09-13 14:39:39 +02:00
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ImageProcessingFaceEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="process_faces",
|
|
|
|
arg_types={
|
|
|
|
1: "list[FaceInformation]",
|
|
|
|
2: "int",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-11-17 10:58:46 +01:00
|
|
|
"humidifier": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-11-17 10:58:46 +01:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="HumidifierEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="available_modes",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:51:23 +01:00
|
|
|
return_type=["HumidifierDeviceClass", None],
|
2022-11-17 10:58:46 +01:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="min_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type=["float"],
|
2022-11-17 10:58:46 +01:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="max_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type=["float"],
|
2022-11-17 10:58:46 +01:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:14:19 +01:00
|
|
|
return_type="HumidifierEntityFeature",
|
2022-11-17 10:58:46 +01:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_humidity",
|
2024-03-27 11:19:20 +01:00
|
|
|
return_type=["float", None],
|
2022-11-17 10:58:46 +01:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_humidity",
|
2023-01-05 00:58:08 +01:00
|
|
|
arg_types={1: "int"},
|
2022-11-17 10:58:46 +01:00
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_mode",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-29 12:51:37 +02:00
|
|
|
"light": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-29 12:51:37 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="LightEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="brightness",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="color_mode",
|
|
|
|
return_type=["ColorMode", "str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="hs_color",
|
|
|
|
return_type=["tuple[float, float]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="xy_color",
|
|
|
|
return_type=["tuple[float, float]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="rgb_color",
|
|
|
|
return_type=["tuple[int, int, int]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="rgbw_color",
|
|
|
|
return_type=["tuple[int, int, int, int]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="rgbww_color",
|
|
|
|
return_type=["tuple[int, int, int, int, int]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="color_temp",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="min_mireds",
|
|
|
|
return_type="int",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="max_mireds",
|
|
|
|
return_type="int",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="effect_list",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="effect",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="capability_attributes",
|
|
|
|
return_type=["dict[str, Any]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_color_modes",
|
|
|
|
return_type=["set[ColorMode]", "set[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:14:47 +01:00
|
|
|
return_type="LightEntityFeature",
|
2022-06-29 12:51:37 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
named_arg_types={
|
|
|
|
"brightness": "int | None",
|
|
|
|
"brightness_pct": "float | None",
|
|
|
|
"brightness_step": "int | None",
|
|
|
|
"brightness_step_pct": "float | None",
|
|
|
|
"color_name": "str | None",
|
|
|
|
"color_temp": "int | None",
|
|
|
|
"effect": "str | None",
|
|
|
|
"flash": "str | None",
|
|
|
|
"kelvin": "int | None",
|
|
|
|
"hs_color": "tuple[float, float] | None",
|
|
|
|
"rgb_color": "tuple[int, int, int] | None",
|
|
|
|
"rgbw_color": "tuple[int, int, int, int] | None",
|
|
|
|
"rgbww_color": "tuple[int, int, int, int, int] | None",
|
|
|
|
"transition": "float | None",
|
|
|
|
"xy_color": "tuple[float, float] | None",
|
|
|
|
"white": "int | None",
|
|
|
|
},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-21 14:36:22 +02:00
|
|
|
"lock": [
|
2022-06-27 12:10:31 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-06-21 14:36:22 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="LockEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="changed_by",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="code_format",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_locked",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_locking",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_unlocking",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_jammed",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
2022-11-17 12:47:48 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:15:11 +01:00
|
|
|
return_type="LockEntityFeature",
|
2022-11-17 12:47:48 +01:00
|
|
|
),
|
2022-06-21 18:53:31 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="lock",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-21 18:53:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="unlock",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-21 18:53:31 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="open",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
2022-06-22 23:51:40 +02:00
|
|
|
has_async_counterpart=True,
|
2022-06-21 18:53:31 +02:00
|
|
|
),
|
2022-06-21 14:36:22 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-09-13 21:55:50 +02:00
|
|
|
"mailbox": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Mailbox",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_type",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="can_delete",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="has_media",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_media",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type="bytes",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_messages",
|
|
|
|
return_type="list[dict[str, Any]]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_delete",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-15 09:48:03 +02:00
|
|
|
"media_player": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-15 09:48:03 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="MediaPlayerEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:57:34 +01:00
|
|
|
return_type=["MediaPlayerDeviceClass", None],
|
2022-08-15 09:48:03 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state",
|
2022-09-07 16:30:22 +02:00
|
|
|
return_type=["MediaPlayerState", None],
|
2022-08-15 09:48:03 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="access_token",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="volume_level",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="is_volume_muted",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_content_id",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_content_type",
|
2022-09-07 16:30:22 +02:00
|
|
|
return_type=["MediaType", "str", None],
|
2022-08-15 09:48:03 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_duration",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_position",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_position_updated_at",
|
|
|
|
return_type=["datetime", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_image_url",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_image_remotely_accessible",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_image_hash",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_media_image",
|
|
|
|
return_type="tuple[bytes | None, str | None]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_browse_image",
|
|
|
|
arg_types={
|
2023-03-26 19:54:01 +02:00
|
|
|
1: "MediaType | str",
|
2022-08-15 09:48:03 +02:00
|
|
|
2: "str",
|
|
|
|
3: "str | None",
|
|
|
|
},
|
|
|
|
return_type="tuple[bytes | None, str | None]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_title",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_artist",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_album_name",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_album_artist",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_track",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_series_title",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_season",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_episode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_channel",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_playlist",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="app_id",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="app_name",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="source",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="source_list",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="sound_mode",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="sound_mode_list",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="shuffle",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="repeat",
|
2022-09-07 16:30:22 +02:00
|
|
|
return_type=["RepeatMode", None],
|
2022-08-15 09:48:03 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="group_members",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
2022-11-17 13:58:34 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:15:37 +01:00
|
|
|
return_type="MediaPlayerEntityFeature",
|
2022-11-17 13:58:34 +01:00
|
|
|
),
|
2022-08-15 09:48:03 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_on",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_off",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="mute_volume",
|
|
|
|
arg_types={
|
|
|
|
1: "bool",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_volume_level",
|
|
|
|
arg_types={
|
|
|
|
1: "float",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_play",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_pause",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_stop",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_previous_track",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_next_track",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_seek",
|
|
|
|
arg_types={
|
|
|
|
1: "float",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="play_media",
|
|
|
|
arg_types={
|
2022-09-07 16:30:22 +02:00
|
|
|
1: "MediaType | str",
|
2022-08-15 09:48:03 +02:00
|
|
|
2: "str",
|
|
|
|
},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="select_source",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="select_sound_mode",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="clear_playlist",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_shuffle",
|
|
|
|
arg_types={
|
|
|
|
1: "bool",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_repeat",
|
|
|
|
arg_types={
|
2022-09-06 18:47:34 +02:00
|
|
|
1: "RepeatMode",
|
2022-08-15 09:48:03 +02:00
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="toggle",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="volume_up",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="volume_down",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_play_pause",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="media_image_local",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="capability_attributes",
|
|
|
|
return_type="dict[str, Any]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_browse_media",
|
|
|
|
arg_types={
|
2023-03-25 05:49:12 +01:00
|
|
|
1: "MediaType | str | None",
|
2022-08-15 09:48:03 +02:00
|
|
|
2: "str | None",
|
|
|
|
},
|
|
|
|
return_type="BrowseMedia",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="join_players",
|
|
|
|
arg_types={
|
|
|
|
1: "list[str]",
|
|
|
|
},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="unjoin_player",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="get_browse_image_url",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
|
|
|
2: "str",
|
|
|
|
3: "str | None",
|
|
|
|
},
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-09-10 23:46:30 +02:00
|
|
|
"notify": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="BaseNotificationService",
|
|
|
|
matches=[
|
2023-01-26 16:23:03 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="targets",
|
2023-03-26 19:52:55 +02:00
|
|
|
return_type=["Mapping[str, Any]", None],
|
2023-01-26 16:23:03 +01:00
|
|
|
),
|
2022-09-10 23:46:30 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="send_message",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-10 16:30:58 +02:00
|
|
|
"number": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-17 16:58:42 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-10 16:30:58 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="NumberEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:58:22 +01:00
|
|
|
return_type=["NumberDeviceClass", None],
|
2022-08-10 16:30:58 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="capability_attributes",
|
|
|
|
return_type="dict[str, Any]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_min_value",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_max_value",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_step",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="mode",
|
|
|
|
return_type="NumberMode",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_unit_of_measurement",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_value",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_native_value",
|
|
|
|
arg_types={1: "float"},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
2022-08-16 19:24:00 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-17 16:58:42 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreNumber",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="extra_restore_state_data",
|
|
|
|
return_type="NumberExtraStoredData",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_last_number_data",
|
|
|
|
return_type=["NumberExtraStoredData", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-16 19:24:00 +02:00
|
|
|
],
|
|
|
|
"remote": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-16 19:24:00 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RemoteEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:06:16 +01:00
|
|
|
function_name="activity_list",
|
|
|
|
return_type=["list[str]", None],
|
2022-08-16 19:24:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_activity",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:06:16 +01:00
|
|
|
function_name="supported_features",
|
2022-11-22 07:16:03 +01:00
|
|
|
return_type="RemoteEntityFeature",
|
2022-08-16 19:24:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="send_command",
|
|
|
|
arg_types={1: "Iterable[str]"},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="learn_command",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="delete_command",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
2022-08-10 16:30:58 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-17 18:44:08 +02:00
|
|
|
"scene": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Scene",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="activate",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-09 16:55:52 +02:00
|
|
|
"select": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-09 16:55:52 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="SelectEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="capability_attributes",
|
|
|
|
return_type="dict[str, Any]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="options",
|
|
|
|
return_type="list[str]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="current_option",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="select_option",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="select_option",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-16 19:22:15 +02:00
|
|
|
"sensor": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-17 18:43:28 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-16 19:22:15 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="SensorEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-08 19:04:58 +01:00
|
|
|
return_type=["SensorDeviceClass", None],
|
2022-08-16 19:22:15 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state_class",
|
|
|
|
return_type=["SensorStateClass", "str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="last_reset",
|
|
|
|
return_type=["datetime", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_value",
|
|
|
|
return_type=[
|
|
|
|
"StateType",
|
|
|
|
"str",
|
|
|
|
"int",
|
|
|
|
"float",
|
|
|
|
None,
|
|
|
|
"date",
|
|
|
|
"datetime",
|
|
|
|
"Decimal",
|
|
|
|
],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_unit_of_measurement",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-17 18:43:28 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreSensor",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="extra_restore_state_data",
|
|
|
|
return_type="SensorExtraStoredData",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_get_last_sensor_data",
|
|
|
|
return_type=["SensorExtraStoredData", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-16 19:22:15 +02:00
|
|
|
],
|
2022-08-09 16:55:52 +02:00
|
|
|
"siren": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-09 16:55:52 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="SirenEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="available_tones",
|
|
|
|
return_type=["dict[int, str]", "list[int | str]", None],
|
|
|
|
),
|
2022-11-17 15:06:26 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:16:29 +01:00
|
|
|
return_type="SirenEntityFeature",
|
2022-11-17 15:06:26 +01:00
|
|
|
),
|
2022-08-09 16:55:52 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-09-12 18:58:06 +02:00
|
|
|
"stt": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Provider",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_languages",
|
|
|
|
return_type="list[str]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_formats",
|
|
|
|
return_type="list[AudioFormats]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_codecs",
|
|
|
|
return_type="list[AudioCodecs]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_bit_rates",
|
|
|
|
return_type="list[AudioBitRates]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_sample_rates",
|
|
|
|
return_type="list[AudioSampleRates]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_channels",
|
|
|
|
return_type="list[AudioChannels]",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_process_audio_stream",
|
2023-03-27 13:09:42 +02:00
|
|
|
arg_types={1: "SpeechMetadata", 2: "AsyncIterable[bytes]"},
|
2022-09-12 18:58:06 +02:00
|
|
|
return_type="SpeechResult",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-18 14:48:23 +02:00
|
|
|
"switch": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-18 14:48:23 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="SwitchEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:50:44 +01:00
|
|
|
return_type=["SwitchDeviceClass", None],
|
2022-08-18 14:48:23 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2023-10-23 22:53:00 +02:00
|
|
|
"todo": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="TodoListEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="todo_items",
|
|
|
|
return_type=["list[TodoItem]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_create_todo_item",
|
|
|
|
arg_types={
|
|
|
|
1: "TodoItem",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_update_todo_item",
|
|
|
|
arg_types={
|
|
|
|
1: "TodoItem",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_delete_todo_items",
|
|
|
|
arg_types={
|
|
|
|
1: "list[str]",
|
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_move_todo_item",
|
|
|
|
arg_types={
|
|
|
|
1: "str",
|
2023-10-26 18:43:10 +02:00
|
|
|
2: "str | None",
|
2023-10-23 22:53:00 +02:00
|
|
|
},
|
|
|
|
return_type="None",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-09-12 23:29:55 +02:00
|
|
|
"tts": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Provider",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="default_language",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_languages",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_options",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="default_options",
|
2023-03-27 11:00:23 +02:00
|
|
|
return_type=["Mapping[str, Any]", None],
|
2022-09-12 23:29:55 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="get_tts_audio",
|
2023-05-24 21:02:55 +02:00
|
|
|
arg_types={1: "str", 2: "str", 3: "dict[str, Any]"},
|
2022-09-12 23:29:55 +02:00
|
|
|
return_type="TtsAudioType",
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-18 13:27:05 +02:00
|
|
|
"update": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="UpdateEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="auto_update",
|
|
|
|
return_type="bool",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="installed_version",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="device_class",
|
2022-12-06 14:50:19 +01:00
|
|
|
return_type=["UpdateDeviceClass", None],
|
2022-08-18 13:27:05 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="in_progress",
|
|
|
|
return_type=["bool", "int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="latest_version",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="release_summary",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="release_url",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:16:53 +01:00
|
|
|
return_type="UpdateEntityFeature",
|
2022-08-18 13:27:05 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="title",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="install",
|
|
|
|
arg_types={1: "str | None", 2: "bool"},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="release_notes",
|
|
|
|
return_type=["str", None],
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-18 19:22:08 +02:00
|
|
|
"vacuum": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-18 19:22:08 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="ToggleEntity",
|
|
|
|
matches=_TOGGLE_ENTITY_MATCH,
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="_BaseVacuum",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="battery_level",
|
|
|
|
return_type=["int", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="battery_icon",
|
|
|
|
return_type="str",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="fan_speed",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="fan_speed_list",
|
|
|
|
return_type="list[str]",
|
|
|
|
),
|
2022-11-17 15:31:09 +01:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:27:27 +01:00
|
|
|
return_type="VacuumEntityFeature",
|
2022-11-17 15:31:09 +01:00
|
|
|
),
|
2022-08-18 19:22:08 +02:00
|
|
|
TypeHintMatch(
|
|
|
|
function_name="stop",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="return_to_base",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="clean_spot",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="locate",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_fan_speed",
|
|
|
|
named_arg_types={
|
|
|
|
"fan_speed": "str",
|
|
|
|
},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="send_command",
|
|
|
|
named_arg_types={
|
|
|
|
"command": "str",
|
|
|
|
"params": "dict[str, Any] | list[Any] | None",
|
|
|
|
},
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="VacuumEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="status",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="start_pause",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_pause",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_start",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="StateVacuumEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="state",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="start",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="pause",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_turn_on",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_turn_off",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="async_toggle",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-17 17:50:00 +02:00
|
|
|
"water_heater": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-17 17:50:00 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="WaterHeaterEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:51:55 +01:00
|
|
|
function_name="current_operation",
|
|
|
|
return_type=["str", None],
|
2022-08-17 17:50:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:51:55 +01:00
|
|
|
function_name="current_temperature",
|
|
|
|
return_type=["float", None],
|
2022-08-17 17:50:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:51:55 +01:00
|
|
|
function_name="is_away_mode_on",
|
|
|
|
return_type=["bool", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="max_temp",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="min_temp",
|
|
|
|
return_type="float",
|
2022-08-17 17:50:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="operation_list",
|
|
|
|
return_type=["list[str]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:51:55 +01:00
|
|
|
function_name="precision",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="supported_features",
|
2022-11-22 07:27:09 +01:00
|
|
|
return_type="WaterHeaterEntityFeature",
|
2022-08-17 17:50:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature_high",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="target_temperature_low",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
2022-11-17 15:51:55 +01:00
|
|
|
function_name="temperature_unit",
|
|
|
|
return_type="str",
|
2022-08-17 17:50:00 +02:00
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_temperature",
|
|
|
|
kwargs_type="Any",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="set_operation_mode",
|
|
|
|
arg_types={1: "str"},
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_away_mode_on",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="turn_away_mode_off",
|
|
|
|
return_type=None,
|
|
|
|
has_async_counterpart=True,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-08-17 16:27:47 +02:00
|
|
|
"weather": [
|
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="Entity",
|
|
|
|
matches=_ENTITY_MATCH,
|
|
|
|
),
|
2023-03-27 20:08:20 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="RestoreEntity",
|
|
|
|
matches=_RESTORE_ENTITY_MATCH,
|
|
|
|
),
|
2022-08-17 16:27:47 +02:00
|
|
|
ClassTypeHintMatch(
|
|
|
|
base_class="WeatherEntity",
|
|
|
|
matches=[
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_temperature",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_temperature_unit",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_pressure",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_pressure_unit",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="humidity",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_wind_speed",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_wind_speed_unit",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="wind_bearing",
|
|
|
|
return_type=["float", "str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="ozone",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_visibility",
|
|
|
|
return_type=["float", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_visibility_unit",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="forecast",
|
|
|
|
return_type=["list[Forecast]", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="native_precipitation_unit",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="precision",
|
|
|
|
return_type="float",
|
|
|
|
),
|
|
|
|
TypeHintMatch(
|
|
|
|
function_name="condition",
|
|
|
|
return_type=["str", None],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
2022-06-01 13:09:53 +02:00
|
|
|
}
|
|
|
|
|
2022-05-31 11:20:31 +02:00
|
|
|
|
|
|
|
def _is_valid_type(
|
2022-06-27 12:10:31 +02:00
|
|
|
expected_type: list[str] | str | None | object,
|
|
|
|
node: nodes.NodeNG,
|
|
|
|
in_return: bool = False,
|
2022-05-31 11:20:31 +02:00
|
|
|
) -> bool:
|
2022-01-24 13:38:56 +01:00
|
|
|
"""Check the argument node against the expected type."""
|
2022-08-01 19:34:06 +02:00
|
|
|
if expected_type is _Special.UNDEFINED:
|
2022-02-03 19:22:43 +01:00
|
|
|
return True
|
|
|
|
|
2022-01-25 18:21:59 +01:00
|
|
|
if isinstance(expected_type, list):
|
|
|
|
for expected_type_item in expected_type:
|
2022-06-27 12:10:31 +02:00
|
|
|
if _is_valid_type(expected_type_item, node, in_return):
|
2022-01-25 18:21:59 +01:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
# Const occurs when the type is None
|
2022-01-25 18:21:59 +01:00
|
|
|
if expected_type is None or expected_type == "None":
|
2022-06-02 07:48:59 +02:00
|
|
|
return isinstance(node, nodes.Const) and node.value is None
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2022-05-31 11:20:31 +02:00
|
|
|
assert isinstance(expected_type, str)
|
|
|
|
|
2022-01-25 18:21:59 +01:00
|
|
|
# Const occurs when the type is an Ellipsis
|
|
|
|
if expected_type == "...":
|
2022-06-02 07:48:59 +02:00
|
|
|
return isinstance(node, nodes.Const) and node.value == Ellipsis
|
2022-01-25 18:21:59 +01:00
|
|
|
|
|
|
|
# Special case for `xxx | yyy`
|
|
|
|
if match := _TYPE_HINT_MATCHERS["a_or_b"].match(expected_type):
|
2022-01-24 18:51:06 +01:00
|
|
|
return (
|
2022-06-02 07:48:59 +02:00
|
|
|
isinstance(node, nodes.BinOp)
|
2022-01-25 18:21:59 +01:00
|
|
|
and _is_valid_type(match.group(1), node.left)
|
|
|
|
and _is_valid_type(match.group(2), node.right)
|
|
|
|
)
|
|
|
|
|
2022-07-10 00:31:09 +02:00
|
|
|
# Special case for `xxx[aaa, bbb, ccc, ...]
|
|
|
|
if (
|
|
|
|
isinstance(node, nodes.Subscript)
|
|
|
|
and isinstance(node.slice, nodes.Tuple)
|
|
|
|
and (
|
|
|
|
match := _TYPE_HINT_MATCHERS[f"x_of_y_{len(node.slice.elts)}"].match(
|
|
|
|
expected_type
|
|
|
|
)
|
2022-05-23 18:51:40 +02:00
|
|
|
)
|
2022-07-10 00:31:09 +02:00
|
|
|
):
|
|
|
|
# This special case is separate because we want Mapping[str, Any]
|
|
|
|
# to also match dict[str, int] and similar
|
|
|
|
if (
|
|
|
|
len(node.slice.elts) == 2
|
|
|
|
and in_return
|
|
|
|
and match.group(1) == "Mapping"
|
|
|
|
and match.group(3) == "Any"
|
|
|
|
):
|
2022-06-27 12:10:31 +02:00
|
|
|
return (
|
2022-07-10 00:31:09 +02:00
|
|
|
isinstance(node.value, nodes.Name)
|
2022-06-27 12:10:31 +02:00
|
|
|
# We accept dict when Mapping is needed
|
|
|
|
and node.value.name in ("Mapping", "dict")
|
|
|
|
and isinstance(node.slice, nodes.Tuple)
|
|
|
|
and _is_valid_type(match.group(2), node.slice.elts[0])
|
|
|
|
# Ignore second item
|
|
|
|
# and _is_valid_type(match.group(3), node.slice.elts[1])
|
|
|
|
)
|
2022-07-10 00:31:09 +02:00
|
|
|
|
|
|
|
# This is the default case
|
2022-01-25 18:21:59 +01:00
|
|
|
return (
|
2022-07-10 00:31:09 +02:00
|
|
|
_is_valid_type(match.group(1), node.value)
|
2022-06-02 07:48:59 +02:00
|
|
|
and isinstance(node.slice, nodes.Tuple)
|
2022-07-10 00:31:09 +02:00
|
|
|
and all(
|
2023-03-26 19:54:21 +02:00
|
|
|
_is_valid_type(match.group(n + 2), node.slice.elts[n], in_return)
|
2022-07-10 00:31:09 +02:00
|
|
|
for n in range(len(node.slice.elts))
|
|
|
|
)
|
2022-01-25 18:21:59 +01:00
|
|
|
)
|
|
|
|
|
2022-07-10 00:31:09 +02:00
|
|
|
# Special case for xxx[yyy]
|
|
|
|
if match := _TYPE_HINT_MATCHERS["x_of_y_1"].match(expected_type):
|
2022-01-25 18:21:59 +01:00
|
|
|
return (
|
2022-06-02 07:48:59 +02:00
|
|
|
isinstance(node, nodes.Subscript)
|
2022-01-25 18:21:59 +01:00
|
|
|
and _is_valid_type(match.group(1), node.value)
|
|
|
|
and _is_valid_type(match.group(2), node.slice)
|
2022-01-24 18:51:06 +01:00
|
|
|
)
|
|
|
|
|
2022-08-10 16:30:58 +02:00
|
|
|
# Special case for float in return type
|
|
|
|
if (
|
|
|
|
expected_type == "float"
|
|
|
|
and in_return
|
|
|
|
and isinstance(node, nodes.Name)
|
|
|
|
and node.name in ("float", "int")
|
|
|
|
):
|
|
|
|
return True
|
|
|
|
|
2024-03-27 11:51:27 +01:00
|
|
|
# Special case for int in argument type
|
|
|
|
if (
|
|
|
|
expected_type == "int"
|
|
|
|
and not in_return
|
|
|
|
and isinstance(node, nodes.Name)
|
|
|
|
and node.name in ("float", "int")
|
|
|
|
):
|
|
|
|
return True
|
|
|
|
|
2024-04-30 11:29:43 +02:00
|
|
|
# Allow subscripts or type aliases for generic types
|
|
|
|
if (
|
|
|
|
isinstance(node, nodes.Subscript)
|
|
|
|
and isinstance(node.value, nodes.Name)
|
|
|
|
and node.value.name in _KNOWN_GENERIC_TYPES
|
|
|
|
or isinstance(node, nodes.Name)
|
|
|
|
and node.name.endswith(_KNOWN_GENERIC_TYPES_TUPLE)
|
|
|
|
):
|
|
|
|
return True
|
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
# Name occurs when a namespace is not used, eg. "HomeAssistant"
|
2022-06-02 07:48:59 +02:00
|
|
|
if isinstance(node, nodes.Name) and node.name == expected_type:
|
2022-01-24 13:38:56 +01:00
|
|
|
return True
|
|
|
|
|
|
|
|
# Attribute occurs when a namespace is used, eg. "core.HomeAssistant"
|
2023-02-07 13:07:21 +01:00
|
|
|
return isinstance(node, nodes.Attribute) and (
|
|
|
|
node.attrname == expected_type or node.as_string() == expected_type
|
|
|
|
)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
|
|
|
|
2022-06-13 11:14:30 +02:00
|
|
|
def _is_valid_return_type(match: TypeHintMatch, node: nodes.NodeNG) -> bool:
|
2022-06-27 12:10:31 +02:00
|
|
|
if _is_valid_type(match.return_type, node, True):
|
2022-06-13 11:14:30 +02:00
|
|
|
return True
|
|
|
|
|
|
|
|
if isinstance(node, nodes.BinOp):
|
|
|
|
return _is_valid_return_type(match, node.left) and _is_valid_return_type(
|
|
|
|
match, node.right
|
|
|
|
)
|
|
|
|
|
2023-03-26 18:37:26 +02:00
|
|
|
if isinstance(match.return_type, (str, list)) and isinstance(node, nodes.Name):
|
2022-09-07 09:44:15 +02:00
|
|
|
if isinstance(match.return_type, str):
|
|
|
|
valid_types = {match.return_type}
|
|
|
|
else:
|
|
|
|
valid_types = {el for el in match.return_type if isinstance(el, str)}
|
2023-03-26 18:37:26 +02:00
|
|
|
if "Mapping[str, Any]" in valid_types:
|
|
|
|
valid_types.add("TypedDict")
|
2022-09-07 09:44:15 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
for infer_node in node.infer():
|
|
|
|
if _check_ancestry(infer_node, valid_types):
|
2022-06-13 11:14:30 +02:00
|
|
|
return True
|
2022-09-07 09:44:15 +02:00
|
|
|
except NameInferenceError:
|
|
|
|
for class_node in node.root().nodes_of_class(nodes.ClassDef):
|
|
|
|
if class_node.name != node.name:
|
|
|
|
continue
|
|
|
|
for infer_node in class_node.infer():
|
|
|
|
if _check_ancestry(infer_node, valid_types):
|
2022-06-13 11:14:30 +02:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2022-09-07 09:44:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
def _check_ancestry(infer_node: InferenceResult, valid_types: set[str]) -> bool:
|
|
|
|
if isinstance(infer_node, nodes.ClassDef):
|
|
|
|
if infer_node.name in valid_types:
|
|
|
|
return True
|
|
|
|
for ancestor in infer_node.ancestors():
|
|
|
|
if ancestor.name in valid_types:
|
|
|
|
return True
|
|
|
|
return False
|
2022-06-13 11:14:30 +02:00
|
|
|
|
|
|
|
|
2022-06-02 07:48:59 +02:00
|
|
|
def _get_all_annotations(node: nodes.FunctionDef) -> list[nodes.NodeNG | None]:
|
2022-01-24 13:38:56 +01:00
|
|
|
args = node.args
|
2022-06-02 07:48:59 +02:00
|
|
|
annotations: list[nodes.NodeNG | None] = (
|
2022-01-24 13:38:56 +01:00
|
|
|
args.posonlyargs_annotations + args.annotations + args.kwonlyargs_annotations
|
|
|
|
)
|
|
|
|
if args.vararg is not None:
|
|
|
|
annotations.append(args.varargannotation)
|
|
|
|
if args.kwarg is not None:
|
|
|
|
annotations.append(args.kwargannotation)
|
|
|
|
return annotations
|
|
|
|
|
|
|
|
|
2022-06-22 12:48:23 +02:00
|
|
|
def _get_named_annotation(
|
|
|
|
node: nodes.FunctionDef, key: str
|
|
|
|
) -> tuple[nodes.NodeNG, nodes.NodeNG] | tuple[None, None]:
|
|
|
|
args = node.args
|
|
|
|
for index, arg_node in enumerate(args.args):
|
|
|
|
if key == arg_node.name:
|
|
|
|
return arg_node, args.annotations[index]
|
|
|
|
|
|
|
|
for index, arg_node in enumerate(args.kwonlyargs):
|
|
|
|
if key == arg_node.name:
|
|
|
|
return arg_node, args.kwonlyargs_annotations[index]
|
|
|
|
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
def _has_valid_annotations(
|
2022-06-02 07:48:59 +02:00
|
|
|
annotations: list[nodes.NodeNG | None],
|
2022-01-24 13:38:56 +01:00
|
|
|
) -> bool:
|
2024-03-11 04:20:37 +01:00
|
|
|
return any(annotation is not None for annotation in annotations)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
|
|
|
|
2022-05-31 11:20:31 +02:00
|
|
|
def _get_module_platform(module_name: str) -> str | None:
|
2023-01-16 20:53:14 +01:00
|
|
|
"""Return the platform for the module name."""
|
2022-05-31 11:20:31 +02:00
|
|
|
if not (module_match := _MODULE_REGEX.match(module_name)):
|
|
|
|
# Ensure `homeassistant.components.<component>`
|
|
|
|
# Or `homeassistant.components.<component>.<platform>`
|
|
|
|
return None
|
|
|
|
|
|
|
|
platform = module_match.groups()[0]
|
|
|
|
return platform.lstrip(".") if platform else "__init__"
|
|
|
|
|
|
|
|
|
2023-02-07 10:21:54 +01:00
|
|
|
def _is_test_function(module_name: str, node: nodes.FunctionDef) -> bool:
|
|
|
|
"""Return True if function is a pytest function."""
|
|
|
|
return module_name.startswith("tests.") and node.name.startswith("test_")
|
|
|
|
|
|
|
|
|
2023-10-02 20:12:43 +02:00
|
|
|
class HassTypeHintChecker(BaseChecker):
|
2022-01-24 13:38:56 +01:00
|
|
|
"""Checker for setup type hints."""
|
|
|
|
|
|
|
|
name = "hass_enforce_type_hints"
|
|
|
|
priority = -1
|
|
|
|
msgs = {
|
2022-06-06 21:43:47 +02:00
|
|
|
"W7431": (
|
2022-08-01 14:09:47 +02:00
|
|
|
"Argument %s should be of type %s in %s",
|
2022-01-24 13:38:56 +01:00
|
|
|
"hass-argument-type",
|
|
|
|
"Used when method argument type is incorrect",
|
|
|
|
),
|
2022-06-06 21:43:47 +02:00
|
|
|
"W7432": (
|
2022-08-01 14:09:47 +02:00
|
|
|
"Return type should be %s in %s",
|
2022-01-24 13:38:56 +01:00
|
|
|
"hass-return-type",
|
|
|
|
"Used when method return type is incorrect",
|
|
|
|
),
|
|
|
|
}
|
2022-06-16 20:12:30 +02:00
|
|
|
options = (
|
|
|
|
(
|
|
|
|
"ignore-missing-annotations",
|
|
|
|
{
|
2022-06-30 20:49:41 +02:00
|
|
|
"default": False,
|
2022-06-16 20:12:30 +02:00
|
|
|
"type": "yn",
|
|
|
|
"metavar": "<y or n>",
|
|
|
|
"help": "Set to ``no`` if you wish to check functions that do not "
|
|
|
|
"have any type hints.",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2023-02-07 10:21:54 +01:00
|
|
|
_class_matchers: list[ClassTypeHintMatch]
|
|
|
|
_function_matchers: list[TypeHintMatch]
|
|
|
|
_module_name: str
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2022-06-02 07:48:59 +02:00
|
|
|
def visit_module(self, node: nodes.Module) -> None:
|
2023-01-16 20:53:14 +01:00
|
|
|
"""Populate matchers for a Module node."""
|
2022-06-01 13:09:53 +02:00
|
|
|
self._class_matchers = []
|
2023-02-07 10:21:54 +01:00
|
|
|
self._function_matchers = []
|
|
|
|
self._module_name = node.name
|
2022-05-31 11:20:31 +02:00
|
|
|
|
|
|
|
if (module_platform := _get_module_platform(node.name)) is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if module_platform in _PLATFORMS:
|
|
|
|
self._function_matchers.extend(_FUNCTION_MATCH["__any_platform__"])
|
|
|
|
|
2022-06-01 13:09:53 +02:00
|
|
|
if function_matches := _FUNCTION_MATCH.get(module_platform):
|
|
|
|
self._function_matchers.extend(function_matches)
|
|
|
|
|
|
|
|
if class_matches := _CLASS_MATCH.get(module_platform):
|
2022-06-21 14:36:22 +02:00
|
|
|
self._class_matchers.extend(class_matches)
|
|
|
|
|
2023-03-27 13:53:14 +02:00
|
|
|
if property_matches := _INHERITANCE_MATCH.get(module_platform):
|
2022-06-21 14:36:22 +02:00
|
|
|
self._class_matchers.extend(property_matches)
|
2022-06-01 13:09:53 +02:00
|
|
|
|
2022-08-10 16:30:58 +02:00
|
|
|
self._class_matchers.reverse()
|
|
|
|
|
2023-02-04 18:52:59 +01:00
|
|
|
def _ignore_function(
|
|
|
|
self, node: nodes.FunctionDef, annotations: list[nodes.NodeNG | None]
|
|
|
|
) -> bool:
|
|
|
|
"""Check if we can skip the function validation."""
|
|
|
|
return (
|
|
|
|
self.linter.config.ignore_missing_annotations
|
|
|
|
and node.returns is None
|
|
|
|
and not _has_valid_annotations(annotations)
|
|
|
|
)
|
|
|
|
|
2022-06-02 07:48:59 +02:00
|
|
|
def visit_classdef(self, node: nodes.ClassDef) -> None:
|
2023-01-16 20:53:14 +01:00
|
|
|
"""Apply relevant type hint checks on a ClassDef node."""
|
2022-06-02 07:48:59 +02:00
|
|
|
ancestor: nodes.ClassDef
|
2022-08-02 00:03:52 +02:00
|
|
|
checked_class_methods: set[str] = set()
|
2022-08-10 16:30:58 +02:00
|
|
|
ancestors = list(node.ancestors()) # cache result for inside loop
|
2024-02-29 16:52:39 +01:00
|
|
|
for class_matcher in self._class_matchers:
|
|
|
|
skip_matcher = False
|
|
|
|
if exclude_base_classes := class_matcher.exclude_base_classes:
|
|
|
|
for ancestor in ancestors:
|
|
|
|
if ancestor.name in exclude_base_classes:
|
|
|
|
skip_matcher = True
|
|
|
|
break
|
|
|
|
if skip_matcher:
|
|
|
|
continue
|
2022-08-10 16:30:58 +02:00
|
|
|
for ancestor in ancestors:
|
2024-02-29 16:52:39 +01:00
|
|
|
if ancestor.name == class_matcher.base_class:
|
2022-08-02 00:03:52 +02:00
|
|
|
self._visit_class_functions(
|
2024-02-29 16:52:39 +01:00
|
|
|
node, class_matcher.matches, checked_class_methods
|
2022-08-02 00:03:52 +02:00
|
|
|
)
|
2022-06-01 13:09:53 +02:00
|
|
|
|
|
|
|
def _visit_class_functions(
|
2022-08-02 00:03:52 +02:00
|
|
|
self,
|
|
|
|
node: nodes.ClassDef,
|
|
|
|
matches: list[TypeHintMatch],
|
|
|
|
checked_class_methods: set[str],
|
2022-06-01 13:09:53 +02:00
|
|
|
) -> None:
|
2022-08-02 00:03:52 +02:00
|
|
|
cached_methods: list[nodes.FunctionDef] = list(node.mymethods())
|
2022-06-01 13:09:53 +02:00
|
|
|
for match in matches:
|
2022-08-02 00:03:52 +02:00
|
|
|
for function_node in cached_methods:
|
2023-02-04 18:52:59 +01:00
|
|
|
if (
|
|
|
|
function_node.name in checked_class_methods
|
|
|
|
or not match.need_to_check_function(function_node)
|
|
|
|
):
|
2022-08-02 00:03:52 +02:00
|
|
|
continue
|
2023-02-04 18:52:59 +01:00
|
|
|
|
|
|
|
annotations = _get_all_annotations(function_node)
|
|
|
|
if self._ignore_function(function_node, annotations):
|
|
|
|
continue
|
|
|
|
|
|
|
|
self._check_function(function_node, match, annotations)
|
|
|
|
checked_class_methods.add(function_node.name)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2022-06-02 07:48:59 +02:00
|
|
|
def visit_functiondef(self, node: nodes.FunctionDef) -> None:
|
2023-01-16 20:53:14 +01:00
|
|
|
"""Apply relevant type hint checks on a FunctionDef node."""
|
2023-02-04 18:52:59 +01:00
|
|
|
annotations = _get_all_annotations(node)
|
|
|
|
if self._ignore_function(node, annotations):
|
|
|
|
return
|
|
|
|
|
|
|
|
# Check that common arguments are correctly typed.
|
|
|
|
for arg_name, expected_type in _COMMON_ARGUMENTS.items():
|
|
|
|
arg_node, annotation = _get_named_annotation(node, arg_name)
|
|
|
|
if arg_node and not _is_valid_type(expected_type, annotation):
|
|
|
|
self.add_message(
|
|
|
|
"hass-argument-type",
|
|
|
|
node=arg_node,
|
|
|
|
args=(arg_name, expected_type, node.name),
|
|
|
|
)
|
|
|
|
|
2023-02-06 16:25:12 +01:00
|
|
|
# Check method or function matchers.
|
|
|
|
if node.is_method():
|
|
|
|
matchers = _METHOD_MATCH
|
|
|
|
else:
|
|
|
|
matchers = self._function_matchers
|
2023-02-07 10:21:54 +01:00
|
|
|
if _is_test_function(self._module_name, node):
|
|
|
|
self._check_test_function(node, annotations)
|
2023-02-06 16:25:12 +01:00
|
|
|
for match in matchers:
|
|
|
|
if not match.need_to_check_function(node):
|
2022-05-31 11:20:31 +02:00
|
|
|
continue
|
2023-02-04 18:52:59 +01:00
|
|
|
self._check_function(node, match, annotations)
|
2022-05-31 11:20:31 +02:00
|
|
|
|
|
|
|
visit_asyncfunctiondef = visit_functiondef
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2023-02-04 18:52:59 +01:00
|
|
|
def _check_function(
|
|
|
|
self,
|
|
|
|
node: nodes.FunctionDef,
|
|
|
|
match: TypeHintMatch,
|
|
|
|
annotations: list[nodes.NodeNG | None],
|
|
|
|
) -> None:
|
2022-06-21 14:36:22 +02:00
|
|
|
# Check that all positional arguments are correctly annotated.
|
|
|
|
if match.arg_types:
|
|
|
|
for key, expected_type in match.arg_types.items():
|
2023-02-07 10:21:54 +01:00
|
|
|
if (
|
|
|
|
node.args.args[key].name in _COMMON_ARGUMENTS
|
|
|
|
or _is_test_function(self._module_name, node)
|
|
|
|
and node.args.args[key].name in _TEST_FIXTURES
|
|
|
|
):
|
2023-02-04 18:52:59 +01:00
|
|
|
# It has already been checked, avoid double-message
|
|
|
|
continue
|
2022-06-21 14:36:22 +02:00
|
|
|
if not _is_valid_type(expected_type, annotations[key]):
|
|
|
|
self.add_message(
|
|
|
|
"hass-argument-type",
|
|
|
|
node=node.args.args[key],
|
2022-08-01 14:09:47 +02:00
|
|
|
args=(key + 1, expected_type, node.name),
|
2022-06-21 14:36:22 +02:00
|
|
|
)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2022-06-22 12:48:23 +02:00
|
|
|
# Check that all keyword arguments are correctly annotated.
|
|
|
|
if match.named_arg_types is not None:
|
|
|
|
for arg_name, expected_type in match.named_arg_types.items():
|
2023-02-07 10:21:54 +01:00
|
|
|
if (
|
|
|
|
arg_name in _COMMON_ARGUMENTS
|
|
|
|
or _is_test_function(self._module_name, node)
|
|
|
|
and arg_name in _TEST_FIXTURES
|
|
|
|
):
|
2023-02-04 18:52:59 +01:00
|
|
|
# It has already been checked, avoid double-message
|
|
|
|
continue
|
2022-06-22 12:48:23 +02:00
|
|
|
arg_node, annotation = _get_named_annotation(node, arg_name)
|
|
|
|
if arg_node and not _is_valid_type(expected_type, annotation):
|
|
|
|
self.add_message(
|
|
|
|
"hass-argument-type",
|
|
|
|
node=arg_node,
|
2022-08-01 14:09:47 +02:00
|
|
|
args=(arg_name, expected_type, node.name),
|
2022-06-22 12:48:23 +02:00
|
|
|
)
|
|
|
|
|
2022-06-21 18:53:31 +02:00
|
|
|
# Check that kwargs is correctly annotated.
|
|
|
|
if match.kwargs_type and not _is_valid_type(
|
|
|
|
match.kwargs_type, node.args.kwargannotation
|
|
|
|
):
|
|
|
|
self.add_message(
|
|
|
|
"hass-argument-type",
|
|
|
|
node=node,
|
2022-08-01 14:09:47 +02:00
|
|
|
args=(node.args.kwarg, match.kwargs_type, node.name),
|
2022-06-21 18:53:31 +02:00
|
|
|
)
|
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
# Check the return type.
|
2022-06-13 11:14:30 +02:00
|
|
|
if not _is_valid_return_type(match, node.returns):
|
|
|
|
self.add_message(
|
2022-08-01 14:09:47 +02:00
|
|
|
"hass-return-type",
|
|
|
|
node=node,
|
|
|
|
args=(match.return_type or "None", node.name),
|
2022-06-13 11:14:30 +02:00
|
|
|
)
|
2022-01-24 13:38:56 +01:00
|
|
|
|
2023-02-07 10:21:54 +01:00
|
|
|
def _check_test_function(
|
|
|
|
self, node: nodes.FunctionDef, annotations: list[nodes.NodeNG | None]
|
|
|
|
) -> None:
|
|
|
|
# Check the return type.
|
|
|
|
if not _is_valid_return_type(_TEST_FUNCTION_MATCH, node.returns):
|
|
|
|
self.add_message(
|
|
|
|
"hass-return-type",
|
|
|
|
node=node,
|
|
|
|
args=(_TEST_FUNCTION_MATCH.return_type or "None", node.name),
|
|
|
|
)
|
|
|
|
# Check that all positional arguments are correctly annotated.
|
|
|
|
for arg_name, expected_type in _TEST_FIXTURES.items():
|
|
|
|
arg_node, annotation = _get_named_annotation(node, arg_name)
|
|
|
|
if arg_node and not _is_valid_type(expected_type, annotation):
|
|
|
|
self.add_message(
|
|
|
|
"hass-argument-type",
|
|
|
|
node=arg_node,
|
|
|
|
args=(arg_name, expected_type, node.name),
|
|
|
|
)
|
|
|
|
|
2022-01-24 13:38:56 +01:00
|
|
|
|
|
|
|
def register(linter: PyLinter) -> None:
|
|
|
|
"""Register the checker."""
|
|
|
|
linter.register_checker(HassTypeHintChecker(linter))
|