Skip to content
Merged
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
4 changes: 3 additions & 1 deletion roborock/data/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def _convert_to_class_obj(class_type: type, value):
sub_type = get_args(class_type)[0]
return [RoborockBase._convert_to_class_obj(sub_type, obj) for obj in value]
if get_origin(class_type) is dict:
_, value_type = get_args(class_type) # assume keys are only basic types
key_type, value_type = get_args(class_type)
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unpacking will fail with a ValueError: not enough values to unpack when encountering untyped dict fields (e.g., device_status: dict | None at line 242 in this file). For untyped dicts, get_args(dict) returns an empty tuple ().

Consider adding a check for this case:

args = get_args(class_type)
if not args:
    # Untyped dict - no conversion needed
    return value
key_type, value_type = args
Suggested change
key_type, value_type = get_args(class_type)
args = get_args(class_type)
if not args:
# Untyped dict - no conversion needed
return value
key_type, value_type = args

Copilot uses AI. Check for mistakes.
if key_type is not None:
return {key_type(k): RoborockBase._convert_to_class_obj(value_type, v) for k, v in value.items()}
return {k: RoborockBase._convert_to_class_obj(value_type, v) for k, v in value.items()}
if inspect.isclass(class_type):
if issubclass(class_type, RoborockBase):
Expand Down