]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Enable checks for E711, E712 and E713
authorChristian Berendt <berendt@b1-systems.de>
Fri, 1 Aug 2014 11:10:20 +0000 (13:10 +0200)
committerChristian Berendt <berendt@b1-systems.de>
Fri, 1 Aug 2014 12:34:47 +0000 (14:34 +0200)
* E711 comparison to None should be 'if cond is None:'
* E712 comparison to True should be 'if cond is True:' or 'if cond:'
* E713 test for membership should be 'not in'

Change-Id: I1481209a85fa6db0343d0111e2b19d9fab4538a7

12 files changed:
bin/cinder-rtstool
cinder/db/sqlalchemy/api.py
cinder/tests/api/fakes.py
cinder/tests/api/v2/test_volumes.py
cinder/tests/keymgr/test_key.py
cinder/tests/test_hds_iscsi.py
cinder/utils.py
cinder/volume/api.py
cinder/volume/drivers/emc/emc_smis_common.py
cinder/volume/drivers/eqlx.py
cinder/volume/drivers/netapp/iscsi.py
tox.ini

index fd61d2635592b4d9f8605a0cfe9543cf99a9cf52..a95d47f7e35fcacc3a41ba90fcb0290225a22e06 100755 (executable)
@@ -95,7 +95,7 @@ def add_initiator(target_iqn, initiator_iqn, userid, password):
         if t.dump()['wwn'] == target_iqn:
             target = t
             break
-    if target == None:
+    if target is None:
         raise RtstoolError(_('Could not find target %s') % target_iqn)
 
     tpg = target.tpgs.next()  # get the first one
index 4f3568ffea2f0f39d06c18dcd1f0cddb79df0ef4..062b7b5b677e4379ab4f4c1ab2e95b80c4181198 100644 (file)
@@ -1159,7 +1159,7 @@ def volume_get_all(context, marker, limit, sort_key, sort_dir,
         query = _generate_paginate_query(context, session, marker, limit,
                                          sort_key, sort_dir, filters)
         # No volumes would match, return empty list
-        if query == None:
+        if query is None:
             return []
         return query.all()
 
@@ -1197,7 +1197,7 @@ def volume_get_all_by_project(context, project_id, marker, limit, sort_key,
         query = _generate_paginate_query(context, session, marker, limit,
                                          sort_key, sort_dir, filters)
         # No volumes would match, return empty list
-        if query == None:
+        if query is None:
             return []
         return query.all()
 
@@ -1230,11 +1230,11 @@ def _generate_paginate_query(context, session, marker, limit, sort_key,
         # 'no_migration_targets' is unique, must be either NULL or
         # not start with 'target:'
         if ('no_migration_targets' in filters and
-                filters['no_migration_targets'] == True):
+                filters['no_migration_targets'] is True):
             filters.pop('no_migration_targets')
             try:
                 column_attr = getattr(models.Volume, 'migration_status')
-                conditions = [column_attr == None,
+                conditions = [column_attr == None,  # noqa
                               column_attr.op('NOT LIKE')('target:%')]
                 query = query.filter(or_(*conditions))
             except AttributeError:
@@ -1630,7 +1630,7 @@ def snapshot_get_active_by_window(context, begin, end=None, project_id=None):
     """Return snapshots that were active during window."""
 
     query = model_query(context, models.Snapshot, read_deleted="yes")
-    query = query.filter(or_(models.Snapshot.deleted_at == None,
+    query = query.filter(or_(models.Snapshot.deleted_at == None,  # noqa
                              models.Snapshot.deleted_at > begin))
     query = query.options(joinedload(models.Snapshot.volume))
     if end:
@@ -1952,7 +1952,7 @@ def volume_get_active_by_window(context,
                                 project_id=None):
     """Return volumes that were active during window."""
     query = model_query(context, models.Volume, read_deleted="yes")
-    query = query.filter(or_(models.Volume.deleted_at == None,
+    query = query.filter(or_(models.Volume.deleted_at == None,  # noqa
                              models.Volume.deleted_at > begin))
     if end:
         query = query.filter(models.Volume.created_at < end)
index 4f3bfd7a06f3a100501f39e37575c8c43a0c8452..6fec0c86aed28fcfb19c5b093cd8e14143c357c1 100644 (file)
@@ -120,7 +120,7 @@ class HTTPRequest(webob.Request):
 
     @classmethod
     def blank(cls, *args, **kwargs):
-        if args != None:
+        if args is not None:
             if args[0].find('v1') == 0:
                 kwargs['base_url'] = 'http://localhost/v1'
             else:
index 3e42e2390329f0166dda647abd9eb8b38e1570c6..2103ed1af96eb90b6c227e1e2c4b8f2467aba759 100644 (file)
@@ -913,7 +913,7 @@ class VolumeApiTest(test.TestCase):
                                 viewable_admin_meta=False):
             vols = [stubs.stub_volume(i)
                     for i in xrange(CONF.osapi_max_limit)]
-            if limit == None or limit >= len(vols):
+            if limit is None or limit >= len(vols):
                 return vols
             return vols[:limit]
         self.stubs.Set(db, 'volume_get_all', stub_volume_get_all)
@@ -932,7 +932,7 @@ class VolumeApiTest(test.TestCase):
                                  viewable_admin_meta=False):
             vols = [stubs.stub_volume(i)
                     for i in xrange(100)]
-            if limit == None or limit >= len(vols):
+            if limit is None or limit >= len(vols):
                 return vols
             return vols[:limit]
         self.stubs.Set(db, 'volume_get_all', stub_volume_get_all2)
@@ -950,7 +950,7 @@ class VolumeApiTest(test.TestCase):
                                  viewable_admin_meta=False):
             vols = [stubs.stub_volume(i)
                     for i in xrange(CONF.osapi_max_limit + 100)]
-            if limit == None or limit >= len(vols):
+            if limit is None or limit >= len(vols):
                 return vols
             return vols[:limit]
         self.stubs.Set(db, 'volume_get_all', stub_volume_get_all3)
index d37688ef29be47fa6df8db1e3dd1bf32289e2b27..d5f4ed172f856b9a4739ca4e1a394fabad7b35b1 100644 (file)
@@ -57,11 +57,11 @@ class SymmetricKeyTestCase(KeyTestCase):
     def test___eq__(self):
         self.assertTrue(self.key == self.key)
 
-        self.assertFalse(self.key == None)
+        self.assertFalse(self.key is None)
         self.assertFalse(None == self.key)
 
     def test___ne__(self):
         self.assertFalse(self.key != self.key)
 
-        self.assertTrue(self.key != None)
+        self.assertTrue(self.key is not None)
         self.assertTrue(None != self.key)
index 6a673ef2d8794cc04581bdbe4402551a20420a7a..48bcaffac58a43ac8d62ad59fadcb909a81b5a87 100644 (file)
@@ -310,7 +310,7 @@ class HNASiSCSIDriverTest(test.TestCase):
         self.driver.delete_volume(vol)
         # should not be deletable twice
         prov_loc = self.backend.getVolumebyProvider(vol['provider_location'])
-        self.assertTrue(prov_loc == None)
+        self.assertTrue(prov_loc is None)
 
     def test_extend_volume(self):
         vol = self._create_volume()
@@ -355,7 +355,7 @@ class HNASiSCSIDriverTest(test.TestCase):
         lun = svol['provider_location']
         m_id_to_vol.return_value = svol
         self.driver.delete_snapshot(svol)
-        self.assertTrue(self.backend.getVolumebyProvider(lun) == None)
+        self.assertTrue(self.backend.getVolumebyProvider(lun) is None)
 
     def test_create_volume_from_snapshot(self):
         svol = self._create_volume()
index 0807e94647aabefd27b70d95c762c7ed580b0d6c..3050e129383c18eaeedc90e51e917f2675c12237 100644 (file)
@@ -132,7 +132,7 @@ def check_exclusive_options(**kwargs):
 
 def execute(*cmd, **kwargs):
     """Convenience wrapper around oslo's execute() method."""
-    if 'run_as_root' in kwargs and not 'root_helper' in kwargs:
+    if 'run_as_root' in kwargs and 'root_helper' not in kwargs:
         kwargs['root_helper'] = get_root_helper()
     return processutils.execute(*cmd, **kwargs)
 
index 89355772e5f909bdc726d6edce931b2eceb36a98..a98df15270b65cb4aa0d7d4fe07a8111facfcd4f 100644 (file)
@@ -292,7 +292,7 @@ class API(base.Base):
     def get_all(self, context, marker=None, limit=None, sort_key='created_at',
                 sort_dir='desc', filters=None, viewable_admin_meta=False):
         check_policy(context, 'get_all')
-        if filters == None:
+        if filters is None:
             filters = {}
 
         try:
index f3ff96a061c41c9efafcb7d2d139f3eda72a4bdd..e86af44b427265d11b7e8bf058f53197fdd74a8d 100644 (file)
@@ -1047,7 +1047,7 @@ class EMCSMISCommon():
 
     def _get_storage_type_conffile(self, filename=None):
         """Get the storage type from the config file."""
-        if filename == None:
+        if filename is None:
             filename = self.configuration.cinder_emc_config_file
 
         file = open(filename, 'r')
index 6eec44de0cbb5ffe9cf87771c0832d73dcfd4c76..685b84f1e04603143d1b61d94fe5ad45f4eb1154 100644 (file)
@@ -448,7 +448,7 @@ class DellEQLSanISCSIDriver(SanISCSIDriver):
             out = self._eql_execute('volume', 'select', volume['name'],
                                     'access', 'show')
             connection_id = self._parse_connection(connector, out)
-            if connection_id != None:
+            if connection_id is not None:
                 self._eql_execute('volume', 'select', volume['name'],
                                   'access', 'delete', connection_id)
         except Exception:
index 630b87b8dc1f3db8be58699e3ea37bf6abdc79c3..30963e1e9574d6465eb6e14660571b5cb02892cf 100644 (file)
@@ -1527,7 +1527,7 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
         vols = self._get_filer_volumes()
         for vol in vols:
             volume = vol.get_child_content('name')
-            if self.volume_list and not volume in self.volume_list:
+            if self.volume_list and volume not in self.volume_list:
                 continue
             state = vol.get_child_content('state')
             inconsistent = vol.get_child_content('is-inconsistent')
diff --git a/tox.ini b/tox.ini
index 87feb47c141c037bd08697ac7d36e02035551f8a..51416a3cd177d60819bccda79e935cce995187e2 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -72,7 +72,7 @@ commands = {posargs}
 # F841,H302,H305,H307,H405
 
 
-ignore = E251,E265,E711,E712,E713,F402,F841,H104,H302,H305,H307,H402,H405,H803,H904
+ignore = E251,E265,F402,F841,H104,H302,H305,H307,H402,H405,H803,H904
 builtins = _
 exclude = .git,.venv,.tox,dist,tools,doc,common,*egg,build