Skip to content

Commit d94aa48

Browse files
authored
fix: typing and error checking (#149)
* fix: typing and error checking * chore: lint * fix: merge weirdness
1 parent 59a59db commit d94aa48

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

roborock/containers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ class RoborockBase:
8989
def from_dict(cls, data: dict[str, Any]):
9090
if isinstance(data, dict):
9191
ignore_keys = cls._ignore_keys
92-
return from_dict(cls, decamelize_obj(data, ignore_keys), config=Config(cast=[Enum]))
92+
try:
93+
return from_dict(cls, decamelize_obj(data, ignore_keys), config=Config(cast=[Enum]))
94+
except AttributeError as err:
95+
raise RoborockException("It seems like you have an outdated version of dacite.") from err
9396

9497
def as_dict(self) -> dict:
9598
return asdict(
@@ -212,8 +215,8 @@ class HomeDataDevice(RoborockBase):
212215

213216
@dataclass
214217
class HomeDataRoom(RoborockBase):
215-
id: Any | None = None
216-
name: Any | None = None
218+
id: int
219+
name: str
217220

218221

219222
@dataclass
@@ -226,7 +229,7 @@ class HomeData(RoborockBase):
226229
lon: Any | None = None
227230
lat: Any | None = None
228231
geo_name: Any | None = None
229-
rooms: list[HomeDataRoom] | None = None
232+
rooms: list[HomeDataRoom] = field(default_factory=list)
230233

231234
def get_all_devices(self) -> list[HomeDataDevice]:
232235
devices = []

0 commit comments

Comments
 (0)