diff --git a/HACKING.rst b/HACKING.rst index 618cfa3095..d16d3009a7 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -50,8 +50,8 @@ done in the OpenStack CI systems. Heat Specific Commandments -------------------------- -- [Heat301] Use LOG.warning() rather than LOG.warn(). -- [Heat302] Python 3: do not use dict.iteritems. -- [Heat303] Python 3: do not use dict.iterkeys. -- [Heat304] Python 3: do not use dict.itervalues. +- [HE301] Use LOG.warning() rather than LOG.warn(). +- [HE302] Python 3: do not use dict.iteritems. +- [HE303] Python 3: do not use dict.iterkeys. +- [HE304] Python 3: do not use dict.itervalues. diff --git a/heat/cloudinit/part_handler.py b/heat/cloudinit/part_handler.py index 50318f3bbc..cf879fee41 100644 --- a/heat/cloudinit/part_handler.py +++ b/heat/cloudinit/part_handler.py @@ -19,7 +19,7 @@ import sys def list_types(): - return(["text/x-cfninitdata"]) + return ["text/x-cfninitdata"] def handle_part(data, ctype, filename, payload): diff --git a/heat/engine/clients/os/keystone/heat_keystoneclient.py b/heat/engine/clients/os/keystone/heat_keystoneclient.py index 7f993ec9c9..a8dd7a6ed1 100644 --- a/heat/engine/clients/os/keystone/heat_keystoneclient.py +++ b/heat/engine/clients/os/keystone/heat_keystoneclient.py @@ -277,7 +277,7 @@ class KsClientWrapper(object): return trust_context def _get_username(self, username): - if(len(username) > 255): + if len(username) > 255: LOG.warning("Truncating the username %s to the last 255 " "characters.", username) # get the last 255 characters of the username diff --git a/heat/engine/resource.py b/heat/engine/resource.py index c8e5c0ecbe..e40fdb98b2 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -809,7 +809,7 @@ class Resource(status.ResourceStatus): if endpoint_exists: req_extension = cls.required_service_extension if not req_extension: - return(True, None) + return (True, None) if isinstance(req_extension, str): req_extension = re.split(' |,', req_extension) for ext in req_extension: diff --git a/heat/engine/resources/openstack/neutron/port.py b/heat/engine/resources/openstack/neutron/port.py index a06fbf3590..58f30296d9 100644 --- a/heat/engine/resources/openstack/neutron/port.py +++ b/heat/engine/resources/openstack/neutron/port.py @@ -545,7 +545,7 @@ class Port(neutron.NeutronResource): ).get_secgroup_uuids(['default']) if self.REPLACEMENT_POLICY in props: - del(props[self.REPLACEMENT_POLICY]) + del props[self.REPLACEMENT_POLICY] def _store_config_default_properties(self, attrs): """A method for storing properties default values. diff --git a/heat/engine/resources/openstack/neutron/security_group.py b/heat/engine/resources/openstack/neutron/security_group.py index 0bd867c75a..f88d58972c 100644 --- a/heat/engine/resources/openstack/neutron/security_group.py +++ b/heat/engine/resources/openstack/neutron/security_group.py @@ -180,7 +180,7 @@ class SecurityGroup(neutron.NeutronResource): if 'remote_mode' in rule: remote_mode = rule.get(self.RULE_REMOTE_MODE) - del(rule[self.RULE_REMOTE_MODE]) + del rule[self.RULE_REMOTE_MODE] if remote_mode == self.RULE_REMOTE_GROUP_ID: rule[self.RULE_REMOTE_IP_PREFIX] = None diff --git a/heat/engine/stack.py b/heat/engine/stack.py index c7ebec1296..912b3c1ac4 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -1343,7 +1343,7 @@ class Stack(collections.abc.Mapping): elif create_if_missing: kwargs = self.get_kwargs_for_cloning(keep_tags=True) kwargs['owner_id'] = self.id - del(kwargs['prev_raw_template_id']) + del kwargs['prev_raw_template_id'] prev = type(self)(self.context, self._backup_name(), copy.deepcopy(self.t), **kwargs) diff --git a/heat/hacking/checks.py b/heat/hacking/checks.py index 4c39435383..dcce567d73 100644 --- a/heat/hacking/checks.py +++ b/heat/hacking/checks.py @@ -26,7 +26,7 @@ Guidelines for writing new hacking checks - Pick numbers in the range H3xx. Find the current test with the highest allocated number and then pick the next value. - Keep the test method code in the source file ordered based - on the Heat3xx value. + on the HE3xx value. - List the new rule in the top level HACKING.rst file - Add test cases for each new rule to heat/tests/test_hacking.py @@ -39,31 +39,31 @@ def no_log_warn(logical_line): https://bugs.launchpad.net/tempest/+bug/1508442 - Heat301 + HE301 """ if logical_line.startswith('LOG.warn('): - yield(0, 'Heat301 Use LOG.warning() rather than LOG.warn()') + yield (0, 'HE301 Use LOG.warning() rather than LOG.warn()') @core.flake8ext def check_python3_no_iteritems(logical_line): - msg = ("Heat302: Use dict.items() instead of dict.iteritems().") + msg = ("HE302: Use dict.items() instead of dict.iteritems().") if re.search(r".*\.iteritems\(\)", logical_line): - yield(0, msg) + yield (0, msg) @core.flake8ext def check_python3_no_iterkeys(logical_line): - msg = ("Heat303: Use dict.keys() instead of dict.iterkeys().") + msg = ("HE303: Use dict.keys() instead of dict.iterkeys().") if re.search(r".*\.iterkeys\(\)", logical_line): - yield(0, msg) + yield (0, msg) @core.flake8ext def check_python3_no_itervalues(logical_line): - msg = ("Heat304: Use dict.values() instead of dict.itervalues().") + msg = ("HE304: Use dict.values() instead of dict.itervalues().") if re.search(r".*\.itervalues\(\)", logical_line): - yield(0, msg) + yield (0, msg) diff --git a/heat/tests/api/cfn/test_api_cfn_v1.py b/heat/tests/api/cfn/test_api_cfn_v1.py index 88d3764c68..f0785213b7 100644 --- a/heat/tests/api/cfn/test_api_cfn_v1.py +++ b/heat/tests/api/cfn/test_api_cfn_v1.py @@ -266,8 +266,8 @@ class CfnStackControllerTest(common.HeatTestCase): u'stack_status': u'COMPLETE', u'description': u'blah', u'disable_rollback': 'true', - u'timeout_mins':60, - u'capabilities':[]}] + u'timeout_mins': 60, + u'capabilities': []}] self.m_call.side_effect = [identity, engine_resp] @@ -358,8 +358,8 @@ class CfnStackControllerTest(common.HeatTestCase): u'stack_status': u'COMPLETE', u'description': u'blah', u'disable_rollback': 'true', - u'timeout_mins':60, - u'capabilities':[]}] + u'timeout_mins': 60, + u'capabilities': []}] self.m_call.return_value = engine_resp diff --git a/heat/tests/api/openstack_v1/test_routes.py b/heat/tests/api/openstack_v1/test_routes.py index 29d1ae4a77..e929423801 100644 --- a/heat/tests/api/openstack_v1/test_routes.py +++ b/heat/tests/api/openstack_v1/test_routes.py @@ -28,8 +28,8 @@ class RoutesTest(common.HeatTestCase): class_name = reflection.get_class_name(route['controller'].controller, fully_qualified=False) self.assertEqual(controller, class_name) - del(route['action']) - del(route['controller']) + del route['action'] + del route['controller'] self.assertEqual(params, route) def setUp(self): diff --git a/heat/tests/api/openstack_v1/test_stacks.py b/heat/tests/api/openstack_v1/test_stacks.py index ff0a57527c..da92d276b7 100644 --- a/heat/tests/api/openstack_v1/test_stacks.py +++ b/heat/tests/api/openstack_v1/test_stacks.py @@ -1608,7 +1608,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): u'stack_status': u'COMPLETE', u'description': u'blah', u'disable_rollback': True, - u'timeout_mins':60, + u'timeout_mins': 60, u'capabilities': [], } ] @@ -1674,7 +1674,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): u'stack_status': u'COMPLETE', u'description': u'blah', u'disable_rollback': True, - u'timeout_mins':60, + u'timeout_mins': 60, u'capabilities': [], } ] diff --git a/heat/tests/convergence/framework/engine_wrapper.py b/heat/tests/convergence/framework/engine_wrapper.py index c1fb47c010..062229c95e 100644 --- a/heat/tests/convergence/framework/engine_wrapper.py +++ b/heat/tests/convergence/framework/engine_wrapper.py @@ -54,13 +54,13 @@ class Engine(message_processor.MessageProcessor): if props: props_def = {} for prop_name, prop_value in props.items(): - if type(prop_value) == scenario_template.GetRes: - prop_res = getattr(prop_value, "target_name") - prop_value = {'get_resource': prop_res} - elif type(prop_value) == scenario_template.GetAtt: + if isinstance(prop_value, scenario_template.GetAtt): prop_res = getattr(prop_value, "target_name") prop_attr = getattr(prop_value, "attr") prop_value = {'get_attr': [prop_res, prop_attr]} + elif isinstance(prop_value, scenario_template.GetRes): + prop_res = getattr(prop_value, "target_name") + prop_value = {'get_resource': prop_res} props_def[prop_name] = prop_value res_defn["properties"] = props_def if depends: diff --git a/heat/tests/openstack/heat/test_none_resource.py b/heat/tests/openstack/heat/test_none_resource.py index 7344b36e5d..28e0879e0a 100644 --- a/heat/tests/openstack/heat/test_none_resource.py +++ b/heat/tests/openstack/heat/test_none_resource.py @@ -76,7 +76,7 @@ outputs: before_refid = self.rsrc.FnGetRefId() self.assertIsNotNone(before_refid) new_t = self.t.copy() - del(new_t['resources']['none']['properties']['ignored']) + del new_t['resources']['none']['properties']['ignored'] utils.update_stack(self.stack, new_t) self.assertEqual((self.stack.UPDATE, self.stack.COMPLETE), self.stack.state) diff --git a/heat/tests/openstack/heat/test_remote_stack.py b/heat/tests/openstack/heat/test_remote_stack.py index b5df410a2a..bbfb0e358b 100644 --- a/heat/tests/openstack/heat/test_remote_stack.py +++ b/heat/tests/openstack/heat/test_remote_stack.py @@ -368,7 +368,7 @@ class RemoteStackTest(tests_common.HeatTestCase): ca_cert=ca_cert) self.assertEqual(ca_cert, rsrc._cacert) self.assertEqual(ca_cert, rsrc.cacert) - self.assertTrue('/tmp/' in rsrc._ssl_verify) + self.assertIn('/tmp/', rsrc._ssl_verify) def test_create_with_insecure(self): rsrc = self._create_with_remote_credential(insecure=True) diff --git a/heat/tests/openstack/heat/test_software_deployment.py b/heat/tests/openstack/heat/test_software_deployment.py index 307ec572fb..db9cf50546 100644 --- a/heat/tests/openstack/heat/test_software_deployment.py +++ b/heat/tests/openstack/heat/test_software_deployment.py @@ -1318,7 +1318,7 @@ class SoftwareDeploymentTest(common.HeatTestCase): mock.call('swift_signal_url')], self.deployment.data_delete.mock_calls) - del(dep_data['swift_signal_object_name']) + del dep_data['swift_signal_object_name'] self.deployment.physical_resource_name = mock.Mock() self.deployment._delete_swift_signal_url() self.assertFalse(self.deployment.physical_resource_name.called) diff --git a/heat/tests/openstack/neutron/test_neutron_floating_ip.py b/heat/tests/openstack/neutron/test_neutron_floating_ip.py index 6915c10779..2ffdf1d054 100644 --- a/heat/tests/openstack/neutron/test_neutron_floating_ip.py +++ b/heat/tests/openstack/neutron/test_neutron_floating_ip.py @@ -156,10 +156,10 @@ class NeutronFloatingIPTest(common.HeatTestCase): raise ex def find_network_port(self, value): - return('9c1eb3fe-7bba-479d-bd43-fdb0bc7cd151') + return '9c1eb3fe-7bba-479d-bd43-fdb0bc7cd151' def find_network_ip(self, value): - return('477e8273-60a7-4c41-b683-1d497e53c384') + return '477e8273-60a7-4c41-b683-1d497e53c384' self.ctx = utils.dummy_context() tpl = template_format.parse(neutron_floating_template) @@ -694,7 +694,7 @@ class NeutronFloatingIPTest(common.HeatTestCase): # test update FloatingIp with None port_id props = copy.deepcopy(fip.properties.data) - del(props['port_id']) + del props['port_id'] update_snippet = rsrc_defn.ResourceDefinition(fip.name, fip.type(), stack.t.parse(stack.defn, props)) diff --git a/heat/tests/test_common_context.py b/heat/tests/test_common_context.py index 95a08ec963..91401d29cf 100644 --- a/heat/tests/test_common_context.py +++ b/heat/tests/test_common_context.py @@ -125,7 +125,7 @@ class TestRequestContext(common.HeatTestCase): user_domain_id=ctx_origin.get('user_domain_id'), project_domain_id=ctx_origin.get('project_domain_id')) ctx_dict = ctx.to_dict() - del(ctx_dict['request_id']) + del ctx_dict['request_id'] self.assertEqual(ctx_origin, ctx_dict) def test_request_context_from_dict(self): diff --git a/heat/tests/test_environment.py b/heat/tests/test_environment.py index 6de00dc9f7..6b1ab0b3a9 100644 --- a/heat/tests/test_environment.py +++ b/heat/tests/test_environment.py @@ -47,7 +47,7 @@ class EnvironmentTest(common.HeatTestCase): u'resource_registry': {u'resources': {}}} env = environment.Environment(old) self.assertEqual(expected, env.env_as_dict()) - del(expected['encrypted_param_names']) + del expected['encrypted_param_names'] self.assertEqual(expected, env.user_env_as_dict()) def test_load_new_env(self): @@ -59,7 +59,7 @@ class EnvironmentTest(common.HeatTestCase): u'resources': {}}} env = environment.Environment(new_env) self.assertEqual(new_env, env.env_as_dict()) - del(new_env['encrypted_param_names']) + del new_env['encrypted_param_names'] self.assertEqual(new_env, env.user_env_as_dict()) def test_global_registry(self): diff --git a/heat/tests/test_template_format.py b/heat/tests/test_template_format.py index 3ce127c246..aeb2368e8b 100644 --- a/heat/tests/test_template_format.py +++ b/heat/tests/test_template_format.py @@ -56,12 +56,12 @@ class JsonToYamlTest(common.HeatTestCase): self.assertEqual(u'2012-12-12', yml[u'HeatTemplateFormatVersion']) self.assertNotIn(u'AWSTemplateFormatVersion', yml) - del(yml[u'HeatTemplateFormatVersion']) + del yml[u'HeatTemplateFormatVersion'] jsn = template_format.parse(json_str) if u'AWSTemplateFormatVersion' in jsn: - del(jsn[u'AWSTemplateFormatVersion']) + del jsn[u'AWSTemplateFormatVersion'] self.assertEqual(yml, jsn) @@ -189,7 +189,7 @@ class JsonYamlResolvedCompareTest(common.HeatTestCase): def compare_stacks(self, json_file, yaml_file, parameters): t1 = self.load_template(json_file) t2 = self.load_template(yaml_file) - del(t1[u'AWSTemplateFormatVersion']) + del t1[u'AWSTemplateFormatVersion'] t1[u'HeatTemplateFormatVersion'] = t2[u'HeatTemplateFormatVersion'] stack1 = utils.parse_stack(t1, parameters) stack2 = utils.parse_stack(t2, parameters) @@ -197,10 +197,10 @@ class JsonYamlResolvedCompareTest(common.HeatTestCase): # compare resources separately so that resolved static data # is compared t1nr = dict(stack1.t.t) - del(t1nr['Resources']) + del t1nr['Resources'] t2nr = dict(stack2.t.t) - del(t2nr['Resources']) + del t2nr['Resources'] self.assertEqual(t1nr, t2nr) self.assertEqual(set(stack1), set(stack2)) diff --git a/test-requirements.txt b/test-requirements.txt index 10f00a0058..bea7ec676c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,13 +1,5 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - # Hacking already pins down pep8, pyflakes and flake8 -hacking>=3.0.1,<3.1.0 # Apache-2.0 -# remove this pyflakes from here once you bump the -# hacking to 3.2.0 or above. hacking 3.2.0 takes -# care of pyflakes version compatibilty. -pyflakes>=2.1.1 +hacking>=6.1.0,<6.2.0 # Apache-2.0 bandit!=1.6.0,>=1.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 6cd81ae928..e40e28c356 100644 --- a/tox.ini +++ b/tox.ini @@ -132,10 +132,10 @@ import_exceptions = heat.common.i18n [flake8:local-plugins] extension = - Heat301 = checks:no_log_warn - Heat302 = checks:check_python3_no_iteritems - Heat303 = checks:check_python3_no_iterkeys - Heat304 = checks:check_python3_no_itervalues + HE301 = checks:no_log_warn + HE302 = checks:check_python3_no_iteritems + HE303 = checks:check_python3_no_iterkeys + HE304 = checks:check_python3_no_itervalues paths = ./heat/hacking [testenv:debug]