diff --git a/roborock/data/code_mappings.py b/roborock/data/code_mappings.py index f0279b33..4794a2c5 100644 --- a/roborock/data/code_mappings.py +++ b/roborock/data/code_mappings.py @@ -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: diff --git a/roborock/protocols/b01_q10_protocol.py b/roborock/protocols/b01_q10_protocol.py index 06d57921..94a1e7b3 100644 --- a/roborock/protocols/b01_q10_protocol.py +++ b/roborock/protocols/b01_q10_protocol.py @@ -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