Skip to content

Commit

Permalink
Initialize descriptor extras using factory
Browse files Browse the repository at this point in the history
Also, remove Optional type hint
  • Loading branch information
rytilahti committed Nov 6, 2022
1 parent c15215b commit c74e1b2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions miio/descriptors.py
Expand Up @@ -24,7 +24,7 @@ class ActionDescriptor:
name: str
method_name: Optional[str] = None
method: Optional[Callable] = None
extras: Optional[Dict] = attr.ib(default={})
extras: Dict = attr.ib(factory=dict)


@attr.s(auto_attribs=True)
Expand All @@ -42,7 +42,7 @@ class SensorDescriptor:
name: str
property: str
unit: Optional[str] = None
extras: Optional[Dict] = attr.ib(default={})
extras: Dict = attr.ib(factory=dict)


class SettingType(Enum):
Expand All @@ -63,7 +63,7 @@ class SettingDescriptor:
type = SettingType.Undefined
setter: Optional[Callable] = None
setter_name: Optional[str] = None
extras: Optional[Dict] = attr.ib(default={})
extras: Dict = attr.ib(factory=dict)

def cast_value(self, value):
"""Casts value to the expected type."""
Expand Down

0 comments on commit c74e1b2

Please sign in to comment.