From 032e921cb3ed0cb65c0b5b63e7e674887e182022 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 19 Apr 2023 20:50:10 -1000 Subject: [PATCH] Use sloted dataclass for BluetoothLEAdvertisement (#422) --- aioesphomeapi/model.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/aioesphomeapi/model.py b/aioesphomeapi/model.py index 362e4ec..878f26d 100644 --- a/aioesphomeapi/model.py +++ b/aioesphomeapi/model.py @@ -1,4 +1,5 @@ import enum +import sys from dataclasses import asdict, dataclass, field, fields from functools import cache, lru_cache from typing import ( @@ -19,6 +20,13 @@ from uuid import UUID from .util import fix_float_single_double_conversion +if sys.version_info[:2] < (3, 10): + _dataclass_decorator = dataclass() +else: + _dataclass_decorator = dataclass( # pylint: disable=unexpected-keyword-arg + slots=True + ) + if TYPE_CHECKING: from .api_pb2 import ( # type: ignore BluetoothLEAdvertisementResponse, @@ -842,11 +850,8 @@ def _convert_bluetooth_le_manufacturer_data( return {int(v.uuid, 16): bytes(v.legacy_data) for v in value} # type: ignore -@dataclass(frozen=True) -class BluetoothLEAdvertisement(APIModelBase): - def __post_init__(self) -> None: - """Post init hook disabled.""" - +@_dataclass_decorator +class BluetoothLEAdvertisement: address: int rssi: int address_type: int