Skip to content

Commit cfebd21

Browse files
committed
Use DescriptorCollection instead of bare dict
1 parent 60c07c2 commit cfebd21

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

miio/devicestatus.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import attr
1818

19+
from .descriptorcollection import DescriptorCollection
1920
from .descriptors import (
2021
AccessFlags,
2122
ActionDescriptor,
@@ -34,7 +35,7 @@ class _StatusMeta(type):
3435
def __new__(metacls, name, bases, namespace, **kwargs):
3536
cls = super().__new__(metacls, name, bases, namespace)
3637

37-
cls._descriptors: Dict[str, PropertyDescriptor] = {}
38+
cls._descriptors: DescriptorCollection[PropertyDescriptor] = {}
3839
cls._parent: Optional["DeviceStatus"] = None
3940
cls._embedded: Dict[str, "DeviceStatus"] = {}
4041

@@ -86,7 +87,7 @@ def __repr__(self):
8687
s += ">"
8788
return s
8889

89-
def descriptors(self) -> Dict[str, PropertyDescriptor]:
90+
def descriptors(self) -> DescriptorCollection[PropertyDescriptor]:
9091
"""Return the dict of sensors exposed by the status container.
9192
9293
Use @sensor and @setting decorators to define properties.
@@ -105,8 +106,8 @@ def embed(self, name: str, other: "DeviceStatus"):
105106
self._embedded[name] = other
106107
other._parent = self # type: ignore[attr-defined]
107108

108-
for property_name, prop in other.descriptors().items():
109-
final_name = f"{name}__{property_name}"
109+
for descriptor_name, prop in other.descriptors().items():
110+
final_name = f"{name}__{descriptor_name}"
110111

111112
self._descriptors[final_name] = attr.evolve(
112113
prop, status_attribute=final_name

0 commit comments

Comments
 (0)