Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion roborock/data/code_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def from_code(cls, code: int) -> Self:
raise ValueError(message)

@classmethod
def from_code_optional(cls, code: int) -> RoborockModeEnum | None:
def from_code_optional(cls, code: int) -> Self | None:
"""Gracefully return None if the code does not exist."""
try:
return cls.from_code(code)
except ValueError:
Expand Down
3 changes: 1 addition & 2 deletions roborock/protocols/b01_q10_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def _convert_datapoints(datapoints: dict[str, Any], message: RoborockMessage) ->
except ValueError as e:
raise ValueError(f"dps key is not a valid integer: {e} for {message.payload!r}") from e
if (dps := B01_Q10_DP.from_code_optional(code)) is not None:
# Update from_code to use `Self` on newer python version to remove this type ignore
result[dps] = value # type: ignore[index]
result[dps] = value
return result


Expand Down
Loading