From: Zhiteng Huang Date: Wed, 30 Jul 2014 04:44:05 +0000 (+0800) Subject: Enable F402 checks and fix violations X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3accff25db175f9abf6fa52a4c4a89b449e50451;p=openstack-build%2Fcinder-build.git Enable F402 checks and fix violations 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 --- diff --git a/cinder/api/contrib/used_limits.py b/cinder/api/contrib/used_limits.py index bfcb88f0b..2d8520532 100644 --- a/cinder/api/contrib/used_limits.py +++ b/cinder/api/contrib/used_limits.py @@ -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) diff --git a/cinder/api/contrib/volume_host_attribute.py b/cinder/api/contrib/volume_host_attribute.py index 18042b469..7c984c154 100644 --- a/cinder/api/contrib/volume_host_attribute.py +++ b/cinder/api/contrib/volume_host_attribute.py @@ -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): diff --git a/cinder/api/contrib/volume_image_metadata.py b/cinder/api/contrib/volume_image_metadata.py index 1a06005c7..c2f2e53cb 100644 --- a/cinder/api/contrib/volume_image_metadata.py +++ b/cinder/api/contrib/volume_image_metadata.py @@ -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): diff --git a/cinder/api/contrib/volume_mig_status_attribute.py b/cinder/api/contrib/volume_mig_status_attribute.py index a424f70a0..f54db1b8f 100644 --- a/cinder/api/contrib/volume_mig_status_attribute.py +++ b/cinder/api/contrib/volume_mig_status_attribute.py @@ -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): diff --git a/cinder/api/contrib/volume_tenant_attribute.py b/cinder/api/contrib/volume_tenant_attribute.py index 35b210ecb..04957e226 100644 --- a/cinder/api/contrib/volume_tenant_attribute.py +++ b/cinder/api/contrib/volume_tenant_attribute.py @@ -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 15ce7d545..a9674a4f7 100644 --- 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