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

Use isinstance() instead of type() #7501

Merged
merged 2 commits into from
Nov 8, 2023
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
2 changes: 2 additions & 0 deletions changelogs/fragments/7501-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "ocapi_utils, oci_utils, redfish_utils module utils - replace ``type()`` calls with ``isinstance()`` calls (https://github.com/ansible-collections/community.general/pull/7501)."
2 changes: 1 addition & 1 deletion plugins/module_utils/ocapi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def get_job_status(self, job_uri):
else:
return response
details = response["data"]["Status"].get("Details")
if type(details) is str:
if isinstance(details, str):
details = [details]
health_list = response["data"]["Status"]["Health"]
return_value = {
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/oracle/oci_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ def delete_and_wait(
result[resource_type] = resource
return result
# oci.wait_until() returns an instance of oci.util.Sentinel in case the resource is not found.
if type(wait_response) is not Sentinel:
if not isinstance(wait_response, Sentinel):
resource = to_dict(wait_response.data)
else:
resource["lifecycle_state"] = "DELETED"
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3708,7 +3708,7 @@ def check_location_uri(self, resp_data, resp_uri):
# WORKAROUND
# HPE systems with iLO 4 will have BIOS Attribute Registries location URI as a dictionary with key 'extref'
# Hence adding condition to fetch the Uri
if type(loc['Uri']) is dict and "extref" in loc['Uri'].keys():
if isinstance(loc['Uri'], dict) and "extref" in loc['Uri'].keys():
rsp_uri = loc['Uri']['extref']
if not rsp_uri:
msg = "Language 'en' not found in BIOS Attribute Registries location, URI: %s, response: %s"
Expand Down