mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use classmethod in Tuya TypeData classes (#57627)
This commit is contained in:
parent
158dd1556c
commit
b854a2537f
@ -26,10 +26,10 @@ class IntegerTypeData:
|
|||||||
scale: float
|
scale: float
|
||||||
step: float
|
step: float
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def from_json(data: str) -> IntegerTypeData:
|
def from_json(cls, data: str) -> IntegerTypeData:
|
||||||
"""Load JSON string and return a IntegerTypeData object."""
|
"""Load JSON string and return a IntegerTypeData object."""
|
||||||
return IntegerTypeData(**json.loads(data))
|
return cls(**json.loads(data))
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -38,10 +38,10 @@ class EnumTypeData:
|
|||||||
|
|
||||||
range: list[str]
|
range: list[str]
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def from_json(data: str) -> EnumTypeData:
|
def from_json(cls, data: str) -> EnumTypeData:
|
||||||
"""Load JSON string and return a EnumTypeData object."""
|
"""Load JSON string and return a EnumTypeData object."""
|
||||||
return EnumTypeData(**json.loads(data))
|
return cls(**json.loads(data))
|
||||||
|
|
||||||
|
|
||||||
class TuyaHaEntity(Entity):
|
class TuyaHaEntity(Entity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user