From 8149ccbd3087d6f192c48bbc2077617856a1f615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Fri, 12 Apr 2024 19:02:37 +0200 Subject: [PATCH] Fix "PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation (#1375) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jiri Daněk --- ods_ci/libs/Helpers.py | 16 +++++++--------- ods_ci/utils/scripts/ocm/ocm.py | 25 ++++++++++++------------- pyproject.toml | 1 - 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ods_ci/libs/Helpers.py b/ods_ci/libs/Helpers.py index aef257dda..e1708b782 100644 --- a/ods_ci/libs/Helpers.py +++ b/ods_ci/libs/Helpers.py @@ -122,13 +122,12 @@ def parse_file_for_tolerations(self, filename): print(tolerations) elif line.startswith("Events:"): break + elif saving is True: + tolerations.append(line.strip()) + print(line) + print(tolerations) else: - if saving is True: - tolerations.append(line.strip()) - print(line) - print(tolerations) - else: - continue + continue return tolerations @keyword @@ -196,9 +195,8 @@ def _inference_object_comparison(expected, received, threshold): if expected.split("__")[0] != received.split("__")[0]: failures.append([expected, received]) # else compare values are equal - else: - if not expected == received: - failures.append([expected, received]) + elif not expected == received: + failures.append([expected, received]) _inference_object_comparison(expected, received, threshold) if len(failures) > 0: diff --git a/ods_ci/utils/scripts/ocm/ocm.py b/ods_ci/utils/scripts/ocm/ocm.py index 70d46a22d..7c414b121 100644 --- a/ods_ci/utils/scripts/ocm/ocm.py +++ b/ods_ci/utils/scripts/ocm/ocm.py @@ -1158,19 +1158,18 @@ def compare_with_old_version_file(self): new_data["RUN"] = None write_data_in_json(filename=self.osd_latest_version_data, data=old_data) return None - else: - if self.osd_major_version not in old_data.keys() and self.osd_major_version in new_data.keys(): - old_data[self.osd_major_version] = {"0": "0"} - log.info(old_data.keys()) - lst_to_trigger_job = compare_dicts( - new_data[self.osd_major_version], - old_data[self.osd_major_version], - ) - elif self.osd_major_version in old_data.keys(): - lst_to_trigger_job = compare_dicts( - new_data[self.osd_major_version], - old_data[self.osd_major_version], - ) + elif self.osd_major_version not in old_data.keys() and self.osd_major_version in new_data.keys(): + old_data[self.osd_major_version] = {"0": "0"} + log.info(old_data.keys()) + lst_to_trigger_job = compare_dicts( + new_data[self.osd_major_version], + old_data[self.osd_major_version], + ) + elif self.osd_major_version in old_data.keys(): + lst_to_trigger_job = compare_dicts( + new_data[self.osd_major_version], + old_data[self.osd_major_version], + ) old_data.update(new_data) if self.new_run == "True": diff --git a/pyproject.toml b/pyproject.toml index 7dbc8a3c2..88a8aa885 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,6 @@ ignore = [ "PERF401", # Use a list comprehension to create a transformed list "PLC0415", # `import` should be at the top-level of a file "PLC1901", # `filter_value != ""` can be simplified to `filter_value` as an empty string is falsey - "PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation "PLR6201", # Use a `set` literal when testing for membership "PLR6301", # Method `_render_template` could be a function, class method, or static method "PLW1514", # `codecs.open` in text mode without explicit `encoding` argument