From 11a8f911affe10bacce41ad3474a28aff3417ec3 Mon Sep 17 00:00:00 2001
From: Brandon Palm <bapalm@us.ibm.com>
Date: Mon, 22 Feb 2016 16:20:30 -0600
Subject: [PATCH] Use instanceof instead of type

Adjusted conditional statements to use instanceof when
comparing variables. Instanceof supports inheritance type
checking better than type.

Change-Id: I4ee0004934dc2322d43ef07e797a6811e39a812c
Closes-Bug: 1548530
---
 openstackclient/api/api.py          | 6 +++---
 openstackclient/api/utils.py        | 2 +-
 openstackclient/tests/test_shell.py | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/openstackclient/api/api.py b/openstackclient/api/api.py
index 97eb7e4a75..6a88e7f7d6 100644
--- a/openstackclient/api/api.py
+++ b/openstackclient/api/api.py
@@ -243,14 +243,14 @@ class BaseAPI(KeystoneSession):
         def getlist(kw):
             """Do list call, unwrap resource dict if present"""
             ret = self.list(path, **kw)
-            if type(ret) == dict and resource in ret:
+            if isinstance(ret, dict) and resource in ret:
                 ret = ret[resource]
             return ret
 
         # Search by attribute
         kwargs = {attr: value}
         data = getlist(kwargs)
-        if type(data) == dict:
+        if isinstance(data, dict):
             return data
         if len(data) == 1:
             return data[0]
@@ -283,7 +283,7 @@ class BaseAPI(KeystoneSession):
         """
 
         items = self.list(path)
-        if type(items) == dict:
+        if isinstance(items, dict):
             # strip off the enclosing dict
             key = list(items.keys())[0]
             items = items[key]
diff --git a/openstackclient/api/utils.py b/openstackclient/api/utils.py
index fa759cd349..ab0e23c29d 100644
--- a/openstackclient/api/utils.py
+++ b/openstackclient/api/utils.py
@@ -61,7 +61,7 @@ def simple_filter(
             # Searching data fields
             search_value = d[attr]
         elif (property_field and property_field in d and
-                type(d[property_field]) is dict):
+                isinstance(d[property_field], dict)):
             # Searching a properties field - do this separately because
             # we don't want to fail over to checking the fields if a
             # property name is given.
diff --git a/openstackclient/tests/test_shell.py b/openstackclient/tests/test_shell.py
index c4546d89f2..80b181611a 100644
--- a/openstackclient/tests/test_shell.py
+++ b/openstackclient/tests/test_shell.py
@@ -317,7 +317,7 @@ class TestShellOptions(TestShell):
             if not test_opts[opt][1]:
                 continue
             key = opt2attr(opt)
-            if type(test_opts[opt][0]) is str:
+            if isinstance(test_opts[opt][0], str):
                 cmd = opt + " " + test_opts[opt][0]
             else:
                 cmd = opt
@@ -331,7 +331,7 @@ class TestShellOptions(TestShell):
             if not test_opts[opt][1]:
                 continue
             key = opt2attr(opt)
-            if type(test_opts[opt][0]) is str:
+            if isinstance(test_opts[opt][0], str):
                 cmd = opt + " " + test_opts[opt][0]
             else:
                 cmd = opt