[blivet:master 1/3] Suppress some unused variable warnings

mulhern amulhern at redhat.com
Mon Mar 24 17:35:35 UTC 2014


Suppose we have some code:

for (x, y, z) in <some list of tuples>:
    # do something with x
    # do something with y

Then z will be reported as an unused variable. But really, there is
no more elegant way to give x and y names, so it's better to supress
the warning about z.

We do that by preceding the variable name with an underscore,
like _z.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devices.py                   | 8 +++++---
 blivet/fcoe.py                      | 2 +-
 blivet/formats/fs.py                | 2 +-
 blivet/iscsi.py                     | 2 +-
 blivet/tsort.py                     | 2 +-
 examples/common.py                  | 4 ++--
 scripts/makeupdates                 | 2 +-
 tests/devicelibs_test/baseclass.py  | 2 +-
 tests/devicelibs_test/lvm_test.py   | 2 +-
 tests/formats_test/labeling_test.py | 2 +-
 10 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/blivet/devices.py b/blivet/devices.py
index 85d63f1..acd6780 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -2375,7 +2375,7 @@ class LVMVolumeGroupDevice(DMDevice):
         for lv in self.lvs:
             used += self.align(lv.snapshotSpace, roundup=True)
 
-        for (vname, vsize) in self.voriginSnapshots.items():
+        for (_vname, vsize) in self.voriginSnapshots.items():
             used += self.align(vsize, roundup=True)
 
         return used
@@ -4147,7 +4147,8 @@ class FcoeDiskDevice(DiskDevice, NetworkStorageDevice):
         dcb = True
 
         from .fcoe import fcoe
-        for nic, dcb, auto_vlan in fcoe().nics:
+
+        for nic, dcb, _auto_vlan in fcoe().nics:
             if nic == self.nic:
                 break
         else:
@@ -4618,7 +4619,8 @@ class BTRFSVolumeDevice(BTRFSDevice):
 
     def createSubVolumes(self):
         self._do_temp_mount()
-        for name, subvol in self.subvolumes:
+
+        for _name, subvol in self.subvolumes:
             if subvol.exists:
                 continue
             subvol.create(mountpoint=self._temp_dir_prefix)
diff --git a/blivet/fcoe.py b/blivet/fcoe.py
index aa4618f..8ab0a0d 100644
--- a/blivet/fcoe.py
+++ b/blivet/fcoe.py
@@ -77,7 +77,7 @@ class fcoe(object):
             log.info("No FCoE EDD info found: %s", rc.rstrip())
             return
 
-        (key, val) = rc.strip().split("=", 1)
+        (_key, val) = rc.strip().split("=", 1)
         #if val not in isys.getDeviceProperties():
         #    log.error("Unknown FCoE NIC found in EDD: %s, ignoring", val)
         #    return
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 18bd5fe..f3a8288 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -752,7 +752,7 @@ class FS(DeviceFormat):
         modname = "%s.ko" % self.mountType
 
         if not canmount and os.path.isdir(modpath):
-            for root, dirs, files in os.walk(modpath):
+            for _root, _dirs, files in os.walk(modpath):
                 have = filter(lambda x: x.startswith(modname), files)
                 if len(have) == 1 and have[0].startswith(modname):
                     return True
diff --git a/blivet/iscsi.py b/blivet/iscsi.py
index 06b1f90..db3023d 100644
--- a/blivet/iscsi.py
+++ b/blivet/iscsi.py
@@ -345,7 +345,7 @@ class iscsi(object):
 
             found = found + 1
 
-            (rc, msg) = self.log_into_node(node, user, pw, user_in, pw_in)
+            (rc, _msg) = self.log_into_node(node, user, pw, user_in, pw_in)
             if rc:
                 logged_in = logged_in +1
 
diff --git a/blivet/tsort.py b/blivet/tsort.py
index 0391d71..fb3af3a 100644
--- a/blivet/tsort.py
+++ b/blivet/tsort.py
@@ -85,7 +85,7 @@ def create_graph(items, edges):
     for item in items:
         graph['incoming'][item] = 0
 
-    for (parent, child) in edges:
+    for (_parent, child) in edges:
         graph['incoming'][child] += 1
 
     return graph 
diff --git a/examples/common.py b/examples/common.py
index 467df98..0344833 100644
--- a/examples/common.py
+++ b/examples/common.py
@@ -24,7 +24,7 @@ def create_sparse_file(b, name, size):
     import blivet
     import tempfile
 
-    (fd, path) = tempfile.mkstemp(prefix="blivet.", suffix="-image-%s" % name)
+    (_fd, path) = tempfile.mkstemp(prefix="blivet.", suffix="-image-%s" % name)
 
     file_device = blivet.devices.SparseFileDevice(path, size=size)
     file_device.create()
@@ -33,7 +33,7 @@ def create_sparse_file(b, name, size):
 def tear_down_disk_images(b):
     """ Tear down any disk image stacks. """
     b.devicetree.teardownAll()
-    for (name, path) in b.config.diskImages.items():
+    for (name, _path) in b.config.diskImages.items():
         dm_device = b.devicetree.getDeviceByName(name)
         if not dm_device:
             continue
diff --git a/scripts/makeupdates b/scripts/makeupdates
index 788e3a8..6992f0a 100755
--- a/scripts/makeupdates
+++ b/scripts/makeupdates
@@ -163,7 +163,7 @@ def main(argv):
     add_rpms = []
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'a:t:o:kc?',
+        opts, _args = getopt.getopt(sys.argv[1:], 'a:t:o:kc?',
                                    ['add=', 'tag=', 'offset=',
                                     'keep', 'compile', 'help'])
     except getopt.GetoptError:
diff --git a/tests/devicelibs_test/baseclass.py b/tests/devicelibs_test/baseclass.py
index 0209898..a203af5 100644
--- a/tests/devicelibs_test/baseclass.py
+++ b/tests/devicelibs_test/baseclass.py
@@ -47,7 +47,7 @@ def getFreeLoopDev():
     out = None
 
     while True:
-        (out, err) = proc.communicate()
+        (out, _err) = proc.communicate()
         if proc.returncode is not None:
             rc = proc.returncode
             out = out.strip()
diff --git a/tests/devicelibs_test/lvm_test.py b/tests/devicelibs_test/lvm_test.py
index d239748..f4f6e3e 100755
--- a/tests/devicelibs_test/lvm_test.py
+++ b/tests/devicelibs_test/lvm_test.py
@@ -42,7 +42,7 @@ class LVMAsRootTestCase(baseclass.DevicelibsTestCase):
         ## pvcreate
         ##
         # pass
-        for dev, file in self._loopMap.iteritems():
+        for dev, _file in self._loopMap.iteritems():
             self.assertEqual(lvm.pvcreate(dev), None)
 
         # fail
diff --git a/tests/formats_test/labeling_test.py b/tests/formats_test/labeling_test.py
index 8347893..f4b9aa1 100755
--- a/tests/formats_test/labeling_test.py
+++ b/tests/formats_test/labeling_test.py
@@ -48,7 +48,7 @@ class InitializationTestCase(unittest.TestCase):
 
         # all devices are permitted to be passed a label argument of None
         # some will ignore it completely
-        for k, v  in device_formats.items():
+        for _k, v  in device_formats.items():
             self.assertIsNotNone(v(label=None))
 
 class MethodsTestCase(unittest.TestCase):
-- 
1.8.3.1



More information about the anaconda-patches mailing list