Skip to content

Commit

Permalink
can do this if we're desperate for the last few %
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Aug 16, 2024
1 parent a5e363d commit 18e11ac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ def _asdictref_inner(obj) -> dict[str, Any] | Any:
for field in getattr(obj, _FIELDS): # similar to dataclasses.fields()
ret[field] = _asdictref_inner(getattr(obj, field))
return ret
elif isinstance(obj, (tuple, list)):
return type(obj)(_asdictref_inner(v) for v in obj)
else:
return obj
obj_type = type(obj)
if obj_type is list:
return [_asdictref_inner(v) for v in obj]
elif obj_type is tuple:
return tuple(_asdictref_inner(v) for v in obj)
else:
return obj

return _asdictref_inner(obj)

Expand Down

0 comments on commit 18e11ac

Please sign in to comment.