Skip to content

Commit

Permalink
Fix PLW2901 (#254)
Browse files Browse the repository at this point in the history
* Fix PLW2901

Signed-off-by: Joostlek <joostlek@outlook.com>

* Fix PLW2901

Signed-off-by: Joostlek <joostlek@outlook.com>

---------

Signed-off-by: Joostlek <joostlek@outlook.com>
  • Loading branch information
joostlek committed Feb 21, 2024
1 parent fc222c9 commit 0884842
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
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

0 comments on commit 0884842

Please sign in to comment.