Fix type hints for older python versions

This commit is contained in:
Teemu Rytilahti 2024-02-15 15:24:30 +01:00
parent 5baaa84a1d
commit ff7be987d8

View File

@ -1,7 +1,7 @@
"""Generic interface for defining device features.""" """Generic interface for defining device features."""
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, auto from enum import Enum, auto
from typing import TYPE_CHECKING, Any, Callable from typing import TYPE_CHECKING, Any, Callable, Optional, Union
if TYPE_CHECKING: if TYPE_CHECKING:
from .device import Device from .device import Device
@ -25,13 +25,13 @@ class Feature:
#: User-friendly short description #: User-friendly short description
name: str name: str
#: Name of the property that allows accessing the value #: Name of the property that allows accessing the value
attribute_getter: str | Callable attribute_getter: Union[str, Callable]
#: Name of the method that allows changing the value #: Name of the method that allows changing the value
attribute_setter: str | None = None attribute_setter: Optional[str] = None
#: Container storing the data, this overrides 'device' for getters #: Container storing the data, this overrides 'device' for getters
container: Any = None container: Any = None
#: Icon suggestion #: Icon suggestion
icon: str | None = None icon: Optional[str] = None
#: Type of the feature #: Type of the feature
type: FeatureType = FeatureType.Sensor type: FeatureType = FeatureType.Sensor