Add Self typing (4) [mypy 1.0] (#87601)
This commit is contained in:
parent
f7b39aa4a8
commit
ea4e2ab4aa
11 changed files with 32 additions and 19 deletions
|
@ -8,6 +8,7 @@ import struct
|
|||
from typing import Any, Literal, overload
|
||||
|
||||
from tuya_iot import TuyaDevice, TuyaDeviceManager
|
||||
from typing_extensions import Self
|
||||
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
@ -112,12 +113,12 @@ class ElectricityTypeData:
|
|||
voltage: str | None = None
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, data: str) -> ElectricityTypeData:
|
||||
def from_json(cls, data: str) -> Self:
|
||||
"""Load JSON string and return a ElectricityTypeData object."""
|
||||
return cls(**json.loads(data.lower()))
|
||||
|
||||
@classmethod
|
||||
def from_raw(cls, data: str) -> ElectricityTypeData:
|
||||
def from_raw(cls, data: str) -> Self:
|
||||
"""Decode base64 string and return a ElectricityTypeData object."""
|
||||
raw = base64.b64decode(data)
|
||||
voltage = struct.unpack(">H", raw[0:2])[0] / 10.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue