Skip to content

Commit

Permalink
[PR #7501/48e860be backport][stable-8] Use isinstance() instead of ty…
Browse files Browse the repository at this point in the history
…pe() (#7503)

Use isinstance() instead of type() (#7501)

* Replace type comparisons with isinstance() checks.

* Add changelog.

(cherry picked from commit 48e860b)

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
patchback[bot] and felixfontein authored Nov 8, 2023
1 parent 82e1f24 commit 4b84127
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
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

0 comments on commit 4b84127

Please sign in to comment.