Skip to content

Commit

Permalink
Revert "Fix "RET503", # Missing explicit return at the end of funct…
Browse files Browse the repository at this point in the history
…ion able to return non-`None` value (#1357)"

This reverts commit b791898.

This change caused a TypeError issue when trying to do the ocm login,
see [1]

[1] #1357 (comment)
  • Loading branch information
jstourac committed Apr 9, 2024
1 parent b791898 commit be4015e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion ods_ci/libs/DataSciencePipelinesAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def get_default_storage(self):
if "annotations" in storage_class["metadata"]:
if storage_class["metadata"]["annotations"]["storageclass.kubernetes.io/is-default-class"] == "true":
return storage_class["metadata"]["name"]
return None

@keyword
def get_openshift_server(self):
Expand Down
3 changes: 1 addition & 2 deletions ods_ci/utils/scripts/awsOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
from util import execute_command


def aws_configure_execute_cmd(aws_key, aws_value, aws_profile) -> str | None:
def aws_configure_execute_cmd(aws_key, aws_value, aws_profile):
aws_configure_cmd = ["aws", "configure", "set", aws_key, aws_value, "--profile", aws_profile]
ret = execute_command(" ".join(aws_configure_cmd))
if ret is None:
log.error(f"Failed to configure {aws_key}")
return ret
sleep(1)
return ret


def aws_configure(aws_access_key_id, aws_secret_access_key, aws_region, aws_profile="default"):
Expand Down
14 changes: 6 additions & 8 deletions ods_ci/utils/scripts/ocm/ocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def is_oc_obj_existent(self, kind, name, namespace, retries=30, retry_sec_interv
log.error(f"{kind} object called {name} not found (ns: {namespace}).")
return found

def install_rhoam_addon(self, exit_on_failure=True) -> bool:
def install_rhoam_addon(self, exit_on_failure=True):
if not self.is_addon_installed(addon_name="managed-api-service"):
add_vars = {"CIDR": "10.1.0.0/26"}
failure_flags = []
Expand Down Expand Up @@ -642,14 +642,13 @@ def install_rhoam_addon(self, exit_on_failure=True) -> bool:
# self.wait_for_addon_installation_to_complete(addon_name="managed-api-service")
else:
log.info("managed-api-service is already installed on {}".format(self.cluster_name))
return True

def uninstall_rhoam_addon(self, exit_on_failure=True):
"""Uninstalls RHOAM addon"""
self.uninstall_addon(addon_name="managed-api-service", exit_on_failure=exit_on_failure)
self.wait_for_addon_uninstallation_to_complete(addon_name="managed-api-service")

def install_managed_starburst_addon(self, license, exit_on_failure=True) -> bool:
def install_managed_starburst_addon(self, license, exit_on_failure=True):
if not self.is_addon_installed(addon_name="managed-starburst"):
add_vars = {
"NOTIFICATION_EMAIL": self.notification_email,
Expand Down Expand Up @@ -677,7 +676,6 @@ def install_managed_starburst_addon(self, license, exit_on_failure=True) -> bool
# self.wait_for_addon_installation_to_complete(addon_name="managed-starburst")
else:
log.info(f"managed-api-service is already installed on {self.cluster_name}")
return True

def uninstall_managed_starburst_addon(self, exit_on_failure=True):
"""Uninstalls RHOAM addon"""
Expand Down Expand Up @@ -1183,7 +1181,7 @@ def compare_with_old_version_file(self):
write_data_in_json(filename=self.osd_latest_version_data, data=old_data)
log.info("File is updated to : {} ".format(old_data))

def change_cluster_channel_group(self) -> str | None:
def change_cluster_channel_group(self):
"""update the channel using ocm cmd"""
cluster_id = self.get_osd_cluster_id()
run_change_channel_cmd = "ocm --v={} patch /api/clusters_mgmt/v1/clusters/{} --body {}".format(
Expand All @@ -1193,9 +1191,9 @@ def change_cluster_channel_group(self) -> str | None:
ret = execute_command(run_change_channel_cmd)
if ret is None:
log.info("Failed to update the channel to {}".format(self.cluster_name))
return ret
return ret

def update_ocm_policy(self) -> str | None:
def update_ocm_policy(self):
"""update cluster policy to schedule for upgrade osd"""
cluster_id = self.get_osd_cluster_id()
utc_time_cmd = """ oc debug node/"$(oc get nodes | awk 'FNR == 2 {print $1}')"\
Expand Down Expand Up @@ -1223,7 +1221,7 @@ def update_ocm_policy(self) -> str | None:
ret = execute_command(schedule_cluster_upgrade)
if ret is None:
log.info("Failed to Update the Upgrade Policy")
return ret
return ret


if __name__ == "__main__":
Expand Down
5 changes: 2 additions & 3 deletions ods_ci/utils/scripts/rosa/rosaOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def rosa_whoami():
execute_command(" ".join(cmd_rosa_whoami))


def create_account_roles() -> str | None:
def create_account_roles():
cmd_create_account_roles = [
"rosa",
"create",
Expand All @@ -25,7 +25,7 @@ def create_account_roles() -> str | None:
ret = execute_command(" ".join(cmd_create_account_roles))
if ret is None:
log.error("Failed to Create account roles")
return ret
return ret


def rosa_create_cluster(
Expand Down Expand Up @@ -95,7 +95,6 @@ def rosa_create_cluster(
return ret

rosa_describe(cluster_name=cluster_name)
return None


def rosa_describe(cluster_name, jq_filter=""):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ ignore = [
"PLW1514", # `codecs.open` in text mode without explicit `encoding` argument
"PLW2901", # `for` loop variable `tag_it` overwritten by assignment target
"RET501", # Do not explicitly `return None` in function if it is the only possible return value
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"RET504", # Unnecessary assignment to `names` before `return` statement
"RET505", # Unnecessary `else` after `return` statement
"UP015", # Unnecessary open mode parameters
Expand Down

0 comments on commit be4015e

Please sign in to comment.