From a478f34b129faa05050a32501369e56e131669f4 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 21 Feb 2024 14:37:13 +0100 Subject: [PATCH 1/3] fix G002 and G004 (#236) Signed-off-by: Joostlek --- pyproject.toml | 2 -- roombapy/remote_client.py | 10 ++++++---- roombapy/roomba.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 70af6dd..b00b2e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,8 +63,6 @@ ignore = [ "EM102", "FBT002", "FBT003", - "G002", - "G004", "TRY002", "TRY003", "TRY300", diff --git a/roombapy/remote_client.py b/roombapy/remote_client.py index da7379f..563047e 100644 --- a/roombapy/remote_client.py +++ b/roombapy/remote_client.py @@ -122,8 +122,9 @@ def _internal_on_connect(self, client, userdata, flags, rc): # If response code(rc) is 0 then connection was succesfull. if rc != 0 and connection_error is None: self.log.warning( - f"Unknown connection error: ID={rc}." - "Kindly use https://github.com/pschmitt/roombapy/issues/new" + "Unknown connection error: ID=%s." + "Kindly use https://github.com/pschmitt/roombapy/issues/new", + rc, ) connection_error = "UNKNOWN_ERROR" if self.on_connect is not None: @@ -137,8 +138,9 @@ def _internal_on_disconnect(self, client, userdata, rc): # If response code(rc) is 0 then connection was succesfull. if rc != 0 and connection_error is None: self.log.warning( - f"Unknown disconnection error: ID={rc}." - "Kindly use https://github.com/pschmitt/roombapy/issues/new" + "Unknown disconnection error: ID=%s." + "Kindly use https://github.com/pschmitt/roombapy/issues/new", + rc, ) connection_error = "UNKNOWN_ERROR" if self.on_disconnect is not None: diff --git a/roombapy/roomba.py b/roombapy/roomba.py index ff1fc91..5cc9c44 100755 --- a/roombapy/roomba.py +++ b/roombapy/roomba.py @@ -234,7 +234,7 @@ def set_preference(self, preference, setting): tmp = {preference: val} roomba_command = {"state": tmp} str_command = orjson.dumps(roomba_command).decode("utf-8") - self.log.debug("Publishing Roomba Setting : %s" % str_command) + self.log.debug("Publishing Roomba Setting : %s", str_command) self.remote_client.publish("delta", str_command) def dict_merge(self, dct, merge_dct): From 475bf2c27d50f18c54e3a82898f823bb53ccaf47 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 21 Feb 2024 14:41:25 +0100 Subject: [PATCH 2/3] Fix PERF102 (#237) Signed-off-by: Joostlek --- pyproject.toml | 1 - roombapy/roomba.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b00b2e7..df43253 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,6 @@ ignore = [ "D101", # documentation info, should be removed after fixes "D102", # documentation info, should be removed after fixes "D103", # documentation info, should be removed after fixes - "PERF102", "PLE1205", "PLR2004", # Just annoying, not really useful "PLR0912", diff --git a/roombapy/roomba.py b/roombapy/roomba.py index 5cc9c44..55bfe48 100755 --- a/roombapy/roomba.py +++ b/roombapy/roomba.py @@ -248,7 +248,7 @@ def dict_merge(self, dct, merge_dct): :param merge_dct: dct merged into dct :return: None """ - for k, v in merge_dct.items(): + for k in merge_dct: if ( k in dct and isinstance(dct[k], dict) From 9687fe18d552758630818f66ca5b442f18796018 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 21 Feb 2024 14:43:15 +0100 Subject: [PATCH 3/3] Fix PLR1714 (#239) Signed-off-by: Joostlek --- pyproject.toml | 1 - roombapy/roomba.py | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df43253..13db1a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,6 @@ ignore = [ "PLE1205", "PLR2004", # Just annoying, not really useful "PLR0912", - "PLR1714", "PLW2901", "RET507", "SIM102", diff --git a/roombapy/roomba.py b/roombapy/roomba.py index 55bfe48..2960cef 100755 --- a/roombapy/roomba.py +++ b/roombapy/roomba.py @@ -376,10 +376,8 @@ def update_state_machine(self, new_state=None): ] == "none" and self.cleanMissionStatus_phase == "charge" - and ( - self.current_state == ROOMBA_STATES["pause"] - or self.current_state == ROOMBA_STATES["recharge"] - ) + and self.current_state + in (ROOMBA_STATES["pause"], ROOMBA_STATES["recharge"]) ): self.current_state = ROOMBA_STATES["cancelled"] except KeyError: @@ -430,14 +428,14 @@ def update_state_machine(self, new_state=None): # so that we will draw map and can update charge status current_mission = None elif ( - self.current_state == ROOMBA_STATES["stop"] - or self.current_state == ROOMBA_STATES["pause"] + self.current_state + in (ROOMBA_STATES["stop"], ROOMBA_STATES["pause"]) ) and self.cleanMissionStatus_phase == "hmUsrDock": self.current_state = ROOMBA_STATES["cancelled"] elif ( ( - self.current_state == ROOMBA_STATES["hmUsrDock"] - or self.current_state == ROOMBA_STATES["cancelled"] + self.current_state + in (ROOMBA_STATES["hmUsrDock"], ROOMBA_STATES["cancelled"]) ) and self.cleanMissionStatus_phase == "charge" or (