Skip to content

Commit

Permalink
clear up .items()
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Mar 28, 2024
1 parent 66f63bf commit 13ceb73
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mqtt_ros_bridge/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def human_readable_encoding(msg: MsgLike) -> bytes:

def human_readable_encoding_recursive(msg: MsgLike) -> NestedDictionary:
msg_dict: NestedDictionary = {}
for field, field_types in msg.get_fields_and_field_types().items():
for field, field_types in (msg.get_fields_and_field_types()).items():
value = getattr(msg, field)

if isinstance(value, bytes):
Expand Down Expand Up @@ -56,7 +56,8 @@ def human_readable_decoding_recursive(msg_dict: NestedDictionary,

for field, value in msg_dict.items():
if isinstance(getattr(msg, field), bytes):
value = value.encode()
if isinstance(value, str):
value = value.encode()
elif isinstance(value, dict):
value = human_readable_decoding_recursive(value, type(getattr(msg, field)))

Expand Down

0 comments on commit 13ceb73

Please sign in to comment.