mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Improve google_assistant
typing (#86537)
This commit is contained in:
parent
949c88930f
commit
b89a51c63d
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from asyncio import gather
|
from asyncio import gather
|
||||||
from collections.abc import Mapping
|
from collections.abc import Callable, Mapping
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
@ -85,7 +85,7 @@ def _get_registry_entries(
|
|||||||
class AbstractConfig(ABC):
|
class AbstractConfig(ABC):
|
||||||
"""Hold the configuration for Google Assistant."""
|
"""Hold the configuration for Google Assistant."""
|
||||||
|
|
||||||
_unsub_report_state = None
|
_unsub_report_state: Callable[[], None] | None = None
|
||||||
|
|
||||||
def __init__(self, hass):
|
def __init__(self, hass):
|
||||||
"""Initialize abstract config."""
|
"""Initialize abstract config."""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
from homeassistant.components import (
|
from homeassistant.components import (
|
||||||
alarm_control_panel,
|
alarm_control_panel,
|
||||||
@ -161,13 +161,15 @@ COMMAND_SELECT_CHANNEL = f"{PREFIX_COMMANDS}selectChannel"
|
|||||||
COMMAND_LOCATE = f"{PREFIX_COMMANDS}Locate"
|
COMMAND_LOCATE = f"{PREFIX_COMMANDS}Locate"
|
||||||
COMMAND_CHARGE = f"{PREFIX_COMMANDS}Charge"
|
COMMAND_CHARGE = f"{PREFIX_COMMANDS}Charge"
|
||||||
|
|
||||||
TRAITS = []
|
TRAITS: list[type[_Trait]] = []
|
||||||
|
|
||||||
FAN_SPEED_MAX_SPEED_COUNT = 5
|
FAN_SPEED_MAX_SPEED_COUNT = 5
|
||||||
|
|
||||||
|
_TraitT = TypeVar("_TraitT", bound="_Trait")
|
||||||
|
|
||||||
def register_trait(trait):
|
|
||||||
"""Decorate a function to register a trait."""
|
def register_trait(trait: type[_TraitT]) -> type[_TraitT]:
|
||||||
|
"""Decorate a class to register a trait."""
|
||||||
TRAITS.append(trait)
|
TRAITS.append(trait)
|
||||||
return trait
|
return trait
|
||||||
|
|
||||||
@ -288,7 +290,7 @@ class CameraStreamTrait(_Trait):
|
|||||||
name = TRAIT_CAMERA_STREAM
|
name = TRAIT_CAMERA_STREAM
|
||||||
commands = [COMMAND_GET_CAMERA_STREAM]
|
commands = [COMMAND_GET_CAMERA_STREAM]
|
||||||
|
|
||||||
stream_info = None
|
stream_info: dict[str, str] | None = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def supported(domain, features, device_class, _):
|
def supported(domain, features, device_class, _):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user