← Back to team overview

curtin-dev team mailing list archive

[Merge] ~hyask/curtin:skia/pycodestyle into curtin:master

 

Skia has proposed merging ~hyask/curtin:skia/pycodestyle into curtin:master.

Commit message:
pycodestyle: make use of isinstance() instead of type()

Should fix curtin-style-tip job.

Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~hyask/curtin/+git/curtin/+merge/461056
-- 
Your team curtin developers is requested to review the proposed merge of ~hyask/curtin:skia/pycodestyle into curtin:master.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index d84e9ec..695ba30 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -272,7 +272,7 @@ def chzdev_import(data=None, persistent=True, noroot=True, base=None,
     if noroot:
         cmd.extend(['--no-root-update'])
     if base:
-        if type(base) == dict:
+        if isinstance(base, dict):
             cmd.extend(
                 ['--base'] + ["%s=%s" % (k, v) for k, v in base.items()])
         else:
diff --git a/curtin/net/__init__.py b/curtin/net/__init__.py
index 3b02f9d..d833bc5 100644
--- a/curtin/net/__init__.py
+++ b/curtin/net/__init__.py
@@ -307,7 +307,7 @@ def iface_add_subnet(iface, subnet):
     ]
     for key, value in subnet.items():
         if value and key in valid_map:
-            if type(value) == list:
+            if isinstance(value, list):
                 value = " ".join(value)
             if '_' in key:
                 key = key.replace('_', '-')
@@ -345,7 +345,7 @@ def iface_add_attrs(iface, index):
     ]
 
     def add_entry(key, value):
-        if type(value) == list:
+        if isinstance(value, list):
             value = " ".join([str(v) for v in value])
         return "    {} {}\n".format(key, value)
 
diff --git a/curtin/net/network_state.py b/curtin/net/network_state.py
index d8a9e7d..e71b37f 100644
--- a/curtin/net/network_state.py
+++ b/curtin/net/network_state.py
@@ -304,7 +304,7 @@ class NetworkState:
         dns = self.network_state.get('dns')
         if 'address' in command:
             addrs = command['address']
-            if not type(addrs) == list:
+            if not isinstance(addrs, list):
                 addrs = [addrs]
             for addr in addrs:
                 dns['nameservers'].append(addr)
diff --git a/curtin/util.py b/curtin/util.py
index 9ab4829..53e2035 100644
--- a/curtin/util.py
+++ b/curtin/util.py
@@ -401,7 +401,7 @@ class ProcessExecutionError(IOError):
         IOError.__init__(self, message)
 
     def _indent_text(self, text):
-        if type(text) == bytes:
+        if isinstance(text, bytes):
             text = text.decode()
         return text.replace('\n', '\n' + ' ' * self.stdout_indent_level)
 
diff --git a/tests/unittests/test_block_mkfs.py b/tests/unittests/test_block_mkfs.py
index 163cee6..f8c81eb 100644
--- a/tests/unittests/test_block_mkfs.py
+++ b/tests/unittests/test_block_mkfs.py
@@ -19,7 +19,7 @@ class TestBlockMkfs(CiTestCase):
         print("expected:\n{}".format(expected))
 
         for flag in expected:
-            if type(flag) == list:
+            if isinstance(flag, list):
                 flag_name = flag[0]
                 flag_val = flag[1]
                 self.assertIn(flag_name, call)
diff --git a/tests/vmtests/test_network.py b/tests/vmtests/test_network.py
index b7493fb..ad5a8bd 100644
--- a/tests/vmtests/test_network.py
+++ b/tests/vmtests/test_network.py
@@ -326,7 +326,7 @@ class TestNetworkBaseTestsAbs(VMBaseClass):
         # FIXME: remove check?
         # initial check, do we have the correct iface ?
         print('ifname={}'.format(ifname))
-        self.assertTrue(type(ipcfg) == dict, "%s is not dict" % (ipcfg))
+        self.assertTrue(isinstance(ipcfg, dict), "%s is not dict" % (ipcfg))
         print("ipcfg['interface']={}".format(ipcfg['interface']))
         self.assertEqual(ifname, ipcfg['interface'])
 
diff --git a/tests/vmtests/test_network_bridging.py b/tests/vmtests/test_network_bridging.py
index c8c52b3..329a49f 100644
--- a/tests/vmtests/test_network_bridging.py
+++ b/tests/vmtests/test_network_bridging.py
@@ -168,7 +168,7 @@ class TestBridgeNetworkAbs(TestNetworkBaseTestsAbs):
                     return
 
             print('key=%s value=%s' % (param, value))
-            if type(value) == list:
+            if isinstance(value, list):
                 for subval in value:
                     (port, pval) = subval.split(" ")
                     print('param=%s port=%s pval=%s' % (param, port, pval))

Follow ups