]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Enable F402 checks and fix violations
authorZhiteng Huang <zhithuang@ebaysf.com>
Wed, 30 Jul 2014 04:44:05 +0000 (12:44 +0800)
committerRushi Agrawal <rushi.agr@gmail.com>
Wed, 13 Aug 2014 16:31:05 +0000 (22:01 +0530)
This change enables F402 hacking check and fixes all violations found.

[F402] import module from line N shadowed by loop variable

Basically this rule tries to avoid loop variables using the same name as
imported module, for example:

    from cinder import volume
    ...

    for volume in volumes:
        ...

Change-Id: Ie3010616ca87fda113d452fe684e6cff3d5fd978

cinder/api/contrib/used_limits.py
cinder/api/contrib/volume_host_attribute.py
cinder/api/contrib/volume_image_metadata.py
cinder/api/contrib/volume_mig_status_attribute.py
cinder/api/contrib/volume_tenant_attribute.py
tox.ini

index bfcb88f0b95c650d0d003d857c955280b5ab481c..2d8520532b4f5320f7f5b0864842aeee85e813ab 100644 (file)
@@ -38,9 +38,9 @@ class UsedLimitsController(wsgi.Controller):
         }
 
         used_limits = {}
-        for display_name, quota in quota_map.iteritems():
-            if quota in quotas:
-                used_limits[display_name] = quotas[quota]['in_use']
+        for display_name, single_quota in quota_map.iteritems():
+            if single_quota in quotas:
+                used_limits[display_name] = quotas[single_quota]['in_use']
 
         resp_obj.obj['limits']['absolute'].update(used_limits)
 
index 18042b4690894f1a0d45377b7d6c6a520710624d..7c984c1544a9c34ade5e95ac71fc54223a27548f 100644 (file)
@@ -47,8 +47,8 @@ class VolumeHostAttributeController(wsgi.Controller):
         context = req.environ['cinder.context']
         if authorize(context):
             resp_obj.attach(xml=VolumeListHostAttributeTemplate())
-            for volume in list(resp_obj.obj['volumes']):
-                self._add_volume_host_attribute(context, req, volume)
+            for vol in list(resp_obj.obj['volumes']):
+                self._add_volume_host_attribute(context, req, vol)
 
 
 class Volume_host_attribute(extensions.ExtensionDescriptor):
index 1a06005c7fe95d0d4ddc68886bb0bfe5afd615eb..c2f2e53cbc26d950cb2f3980504987ecae604f37 100644 (file)
@@ -76,9 +76,9 @@ class VolumeImageMetadataController(wsgi.Controller):
         if authorize(context):
             resp_obj.attach(xml=VolumesImageMetadataTemplate())
             all_meta = self._get_all_images_metadata(context)
-            for volume in list(resp_obj.obj.get('volumes', [])):
-                image_meta = all_meta.get(volume['id'], {})
-                self._add_image_metadata(context, volume, image_meta)
+            for vol in list(resp_obj.obj.get('volumes', [])):
+                image_meta = all_meta.get(vol['id'], {})
+                self._add_image_metadata(context, vol, image_meta)
 
 
 class Volume_image_metadata(extensions.ExtensionDescriptor):
index a424f70a028db17c96c898a822cadaa15b37d498..f54db1b8f2ddcf266c7b84eeaaa474cd7da1286e 100644 (file)
@@ -48,8 +48,8 @@ class VolumeMigStatusAttributeController(wsgi.Controller):
         context = req.environ['cinder.context']
         if authorize(context):
             resp_obj.attach(xml=VolumeListMigStatusAttributeTemplate())
-            for volume in list(resp_obj.obj['volumes']):
-                self._add_volume_mig_status_attribute(req, context, volume)
+            for vol in list(resp_obj.obj['volumes']):
+                self._add_volume_mig_status_attribute(req, context, vol)
 
 
 class Volume_mig_status_attribute(extensions.ExtensionDescriptor):
index 35b210ecb21c401d722d473c6531c164721a793e..04957e22632c18f1900f2cf1f48234c95e58830f 100644 (file)
@@ -45,8 +45,8 @@ class VolumeTenantAttributeController(wsgi.Controller):
         context = req.environ['cinder.context']
         if authorize(context):
             resp_obj.attach(xml=VolumeListTenantAttributeTemplate())
-            for volume in list(resp_obj.obj['volumes']):
-                self._add_volume_tenant_attribute(context, req, volume)
+            for vol in list(resp_obj.obj['volumes']):
+                self._add_volume_tenant_attribute(context, req, vol)
 
 
 class Volume_tenant_attribute(extensions.ExtensionDescriptor):
diff --git a/tox.ini b/tox.ini
index 15ce7d545faafd6e593915f7bebdd5f2c9e2e42d..a9674a4f705e132efbfb69b234daeee9bf327081 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -72,7 +72,7 @@ commands = {posargs}
 # F841,H302,H305,H307,H405
 
 
-ignore = E251,E265,F402,H302,H305,H307,H402,H405,H803,H904
+ignore = E251,E265,H302,H305,H307,H402,H405,H803,H904
 builtins = _
 exclude = .git,.venv,.tox,dist,tools,doc,common,*egg,build