]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
enable F402 check for flake8
authorMark McClain <mmcclain@yahoo-inc.com>
Thu, 12 Jun 2014 01:23:53 +0000 (21:23 -0400)
committerMark McClain <mmcclain@yahoo-inc.com>
Thu, 23 Oct 2014 21:29:00 +0000 (17:29 -0400)
The change removes the shadowed loop variables and enables F402 checking

Change-Id: I015797feec463ffb0b5e97229a6ec2c9a41df9de
Partial-Bug: 1329017

neutron/db/securitygroups_db.py
neutron/tests/unit/test_agent_ext_plugin.py
neutron/tests/unit/test_l3_agent.py
tox.ini

index 23b5c80cb1136ce06855bb7cefd50cea7431dc10..6fc0d870ec7d2e9d67a082ace9df2c9499c1a50d 100644 (file)
@@ -18,7 +18,7 @@ from sqlalchemy import orm
 from sqlalchemy.orm import exc
 from sqlalchemy.orm import scoped_session
 
-from neutron.api.v2 import attributes as attr
+from neutron.api.v2 import attributes
 from neutron.common import constants
 from neutron.db import db_base_plugin_v2
 from neutron.db import model_base
@@ -481,11 +481,11 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
 
     # Register dict extend functions for ports
     db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(
-        attr.PORTS, ['_extend_port_dict_security_group'])
+        attributes.PORTS, ['_extend_port_dict_security_group'])
 
     def _process_port_create_security_group(self, context, port,
                                             security_group_ids):
-        if attr.is_attr_set(security_group_ids):
+        if attributes.is_attr_set(security_group_ids):
             for security_group_id in security_group_ids:
                 self._create_port_security_group_binding(context, port['id'],
                                                          security_group_id)
@@ -517,7 +517,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
         :returns: all security groups IDs on port belonging to tenant.
         """
         p = port['port']
-        if not attr.is_attr_set(p.get(ext_sg.SECURITYGROUPS)):
+        if not attributes.is_attr_set(p.get(ext_sg.SECURITYGROUPS)):
             return
         if p.get('device_owner') and p['device_owner'].startswith('network:'):
             return
@@ -546,7 +546,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
         tenant_id = self._get_tenant_id_for_create(context,
                                                    port['port'])
         default_sg = self._ensure_default_security_group(context, tenant_id)
-        if attr.is_attr_set(port['port'].get(ext_sg.SECURITYGROUPS)):
+        if attributes.is_attr_set(port['port'].get(ext_sg.SECURITYGROUPS)):
             sgids = port['port'].get(ext_sg.SECURITYGROUPS)
         else:
             sgids = [default_sg]
@@ -557,7 +557,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
         is either [] or not is_attr_set, otherwise return False
         """
         if (ext_sg.SECURITYGROUPS in port['port'] and
-            not (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
+            not (attributes.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
                  and port['port'][ext_sg.SECURITYGROUPS] != [])):
             return True
         return False
@@ -567,7 +567,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
         security_group field is is_attr_set or [].
         """
         if (ext_sg.SECURITYGROUPS in port['port'] and
-            (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) and
+            (attributes.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) and
              port['port'][ext_sg.SECURITYGROUPS] != [])):
             return True
         return False
index ddbf4f02e9b96921bc74187b42285da17e1546e4..a1da827ebe2987636f205f7743dcc316e5a5d342 100644 (file)
@@ -211,12 +211,12 @@ class AgentDBTestCase(AgentDBTestMixIn,
     def test_list_agent(self):
         agents = self._register_agent_states()
         res = self._list('agents')
-        for agent in res['agents']:
-            if (agent['host'] == DHCP_HOSTA and
-                agent['agent_type'] == constants.AGENT_TYPE_DHCP):
+        for agt in res['agents']:
+            if (agt['host'] == DHCP_HOSTA and
+                agt['agent_type'] == constants.AGENT_TYPE_DHCP):
                 self.assertEqual(
                     'dhcp_driver',
-                    agent['configurations']['dhcp_driver'])
+                    agt['configurations']['dhcp_driver'])
                 break
         self.assertEqual(len(agents), len(res['agents']))
 
index df362342d7f2d621fb7330ddb6e91e274ae85a35..c381a66be60c2e34ef5187b360b2a13e11be1568 100644 (file)
@@ -794,9 +794,9 @@ class TestBasicRouterOperations(base.BaseTestCase):
     def _verify_snat_rules(self, rules, router, negate=False):
         interfaces = router[l3_constants.INTERFACE_KEY]
         source_cidrs = []
-        for interface in interfaces:
-            prefix = interface['subnet']['cidr'].split('/')[1]
-            source_cidr = "%s/%s" % (interface['fixed_ips'][0]['ip_address'],
+        for iface in interfaces:
+            prefix = iface['subnet']['cidr'].split('/')[1]
+            source_cidr = "%s/%s" % (iface['fixed_ips'][0]['ip_address'],
                                      prefix)
             source_cidrs.append(source_cidr)
         source_nat_ip = router['gw_port']['fixed_ips'][0]['ip_address']
diff --git a/tox.ini b/tox.ini
index 63abb84613428e707982166dfe38a56c2fac2ecc..9185ac0b8489ad4ccc4a7e973b3396ea4b55c4fe 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -65,7 +65,6 @@ commands = python setup.py build_sphinx
 # E128 continuation line under-indented for visual indent
 # E129 visually indented line with same indent as next logical line
 # E265 block comment should start with ‘# ‘
-# F402 import module shadowed by loop variable
 # F811 redefinition of unused variable
 # F812 list comprehension redefines name from line
 # H237 module is removed in Python 3
@@ -76,7 +75,7 @@ commands = python setup.py build_sphinx
 # H405 multi line docstring summary not separated with an empty line
 # H904 Wrap long lines in parentheses instead of a backslash
 # TODO(marun) H404 multi line docstring should start with a summary
-ignore = E125,E126,E128,E129,E265,F402,F811,F812,H237,H305,H307,H401,H402,H404,H405,H904
+ignore = E125,E126,E128,E129,E265,F811,F812,H237,H305,H307,H401,H402,H404,H405,H904
 show-source = true
 builtins = _
 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios