mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Convert UnitConverter protocol to a class (#78934)
* Convert UnitConverter protocl to a class * Remove logic change * Use TypeVar * Remove NORMALIZED_UNIT from pressure * Reduce size of PR * Reduce some more * Once more * Once more * Remove DEVICE_CLASS
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Typing Helpers for Home Assistant."""
|
||||
from collections.abc import Mapping
|
||||
from enum import Enum
|
||||
from typing import Any, Optional, Protocol, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import homeassistant.core
|
||||
|
||||
@@ -27,16 +27,6 @@ class UndefinedType(Enum):
|
||||
UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
|
||||
|
||||
|
||||
class UnitConverter(Protocol):
|
||||
"""Define the format of a conversion utility."""
|
||||
|
||||
VALID_UNITS: tuple[str, ...]
|
||||
NORMALIZED_UNIT: str
|
||||
|
||||
def convert(self, value: float, from_unit: str, to_unit: str) -> float:
|
||||
"""Convert one unit of measurement to another."""
|
||||
|
||||
|
||||
# The following types should not used and
|
||||
# are not present in the core code base.
|
||||
# They are kept in order not to break custom integrations
|
||||
|
Reference in New Issue
Block a user