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 "RET503", # Missing explicit return at the end of function able to return non-None value #1357

Merged
merged 3 commits into from
Apr 8, 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: 1 addition & 0 deletions ods_ci/libs/DataSciencePipelinesAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ 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: 2 additions & 1 deletion ods_ci/utils/scripts/awsOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from util import execute_command


def aws_configure_execute_cmd(aws_key, aws_value, aws_profile):
def aws_configure_execute_cmd(aws_key, aws_value, aws_profile) -> str | None:
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: 8 additions & 6 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):
def install_rhoam_addon(self, exit_on_failure=True) -> bool:
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,13 +642,14 @@ def install_rhoam_addon(self, exit_on_failure=True):
# 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):
def install_managed_starburst_addon(self, license, exit_on_failure=True) -> bool:
if not self.is_addon_installed(addon_name="managed-starburst"):
add_vars = {
"NOTIFICATION_EMAIL": self.notification_email,
Expand Down Expand Up @@ -676,6 +677,7 @@ def install_managed_starburst_addon(self, license, exit_on_failure=True):
# 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 @@ -1181,7 +1183,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):
def change_cluster_channel_group(self) -> str | None:
"""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 @@ -1191,9 +1193,9 @@ def change_cluster_channel_group(self):
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):
def update_ocm_policy(self) -> str | None:
"""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 @@ -1221,7 +1223,7 @@ def update_ocm_policy(self):
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: 3 additions & 2 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():
def create_account_roles() -> str | None:
cmd_create_account_roles = [
"rosa",
"create",
Expand All @@ -25,7 +25,7 @@ def create_account_roles():
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,6 +95,7 @@ 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: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ 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
Loading