Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PLW2901 #254

Merged
merged 3 commits into from
Feb 21, 2024
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ ignore = [
"ISC001", # Conflicts with other rules
"PLR2004", # Just annoying, not really useful
"PLR0912",
"PLW2901",
]
select = ["ALL"]

Expand Down
43 changes: 25 additions & 18 deletions roombapy/roomba.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,50 +311,57 @@ def decode_topics(self, state, prefix=None):
to strings to avoid unicode representations
"""
for key, value in state.items():
mutable_key = key
if isinstance(value, dict):
if prefix is None:
self.decode_topics(value, key)
else:
self.decode_topics(value, prefix + "_" + key)
else:
mutable_value = value
if isinstance(value, list):
newlist = []
for i in value:
if isinstance(i, dict):
for ki, vi in i.items():
newlist.append((str(ki), vi))
else:
val = i
if isinstance(i, str):
i = str(i)
newlist.append(i)
value = newlist
val = str(i)
newlist.append(val)
mutable_value = newlist
if prefix is not None:
key = prefix + "_" + key
mutable_key = prefix + "_" + key
# all data starts with this, so it's redundant
key = key.replace("state_reported_", "")
mutable_key = mutable_key.replace("state_reported_", "")
# save variables for drawing map
if key == "pose_theta":
self.co_ords["theta"] = value
if key == "pose_point_x": # x and y are reversed...
self.co_ords["y"] = value
if key == "pose_point_y":
self.co_ords["x"] = value
if key == "bin_full":
self.bin_full = value
if key == "cleanMissionStatus_error":
if mutable_key == "pose_theta":
self.co_ords["theta"] = mutable_value
if mutable_key == "pose_point_x": # x and y are reversed...
self.co_ords["y"] = mutable_value
if mutable_key == "pose_point_y":
self.co_ords["x"] = mutable_value
if mutable_key == "bin_full":
self.bin_full = mutable_value
if mutable_key == "cleanMissionStatus_error":
try:
self.error_code = value
self.error_message = ROOMBA_ERROR_MESSAGES[value]
self.error_code = mutable_value
self.error_message = ROOMBA_ERROR_MESSAGES[
mutable_value
]
except KeyError as e:
self.log.warning(
"Error looking up Roomba error message: %s", e
)
self.error_message = "Unknown Error number: %s" % value
self.error_message = (
"Unknown Error number: %s" % mutable_value
)
if key == "cleanMissionStatus_phase":
self.previous_cleanMissionStatus_phase = (
self.cleanMissionStatus_phase
)
self.cleanMissionStatus_phase = value
self.cleanMissionStatus_phase = mutable_value

if prefix is None:
self.update_state_machine()
Expand Down