Enforce multiple previously ignored pep8 rules

This commit removes almost all the pep8 rules from ignore list. Most of
these rules only required minor changes or were redundant and could be
enabled without any changes.

The only rule exclusion left active is E128 to keep the commit small
enough.

Change-Id: Iec4f00cff9e023515082caae525207054341b94b
This commit is contained in:
Kirill Zaitsev 2017-07-05 13:25:32 +03:00
parent 38059cca84
commit 5cc622f42a
14 changed files with 63 additions and 62 deletions

View File

@ -1,4 +1,4 @@
#Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #

View File

@ -147,9 +147,11 @@ class NestedDriver(base.BaseNestedDriver):
try: try:
app.neutron.update_port( app.neutron.update_port(
port_id, port_id,
{'port': { {
'port': {
'allowed_address_pairs': address_pairs 'allowed_address_pairs': address_pairs
}}) }
})
except n_exceptions.NeutronClientException as ex: except n_exceptions.NeutronClientException as ex:
LOG.error("Error happened during updating Neutron " LOG.error("Error happened during updating Neutron "
"port %(port_id)s: %(ex)s", port_id, ex) "port %(port_id)s: %(ex)s", port_id, ex)

View File

@ -58,7 +58,8 @@ class TestNestedDriver(base.TestKuryrBase):
@mock.patch.object(binding, 'port_bind') @mock.patch.object(binding, 'port_bind')
@mock.patch('kuryr_libnetwork.app.neutron.update_port') @mock.patch('kuryr_libnetwork.app.neutron.update_port')
@mock.patch.object(nested.NestedDriver, '_get_port_from_host_iface') @mock.patch.object(nested.NestedDriver, '_get_port_from_host_iface')
def test_create_host_iface(self, mock_get_port_from_host, def test_create_host_iface(
self, mock_get_port_from_host,
mock_update_port, mock_port_bind, mock_conf): mock_update_port, mock_port_bind, mock_conf):
mock_conf.binding.link_iface = 'eth0' mock_conf.binding.link_iface = 'eth0'
@ -109,7 +110,8 @@ class TestNestedDriver(base.TestKuryrBase):
mock_get_port_from_host.assert_called_with('eth0') mock_get_port_from_host.assert_called_with('eth0')
mock_port_bind.assert_called_with(fake_endpoint_id, mock_port_bind.assert_called_with(fake_endpoint_id,
fake_neutron_port, fake_subnets, fake_network, fake_vm_port) fake_neutron_port, fake_subnets, fake_network, fake_vm_port)
mock_update_port.assert_called_with(fake_vm_port['id'], mock_update_port.assert_called_with(
fake_vm_port['id'],
{'port': { {'port': {
'allowed_address_pairs': updated_allowed_pairs 'allowed_address_pairs': updated_allowed_pairs
}}) }})
@ -120,7 +122,8 @@ class TestNestedDriver(base.TestKuryrBase):
@mock.patch.object(binding, 'port_unbind') @mock.patch.object(binding, 'port_unbind')
@mock.patch('kuryr_libnetwork.app.neutron.update_port') @mock.patch('kuryr_libnetwork.app.neutron.update_port')
@mock.patch.object(nested.NestedDriver, '_get_port_from_host_iface') @mock.patch.object(nested.NestedDriver, '_get_port_from_host_iface')
def test_delete_host_iface(self, mock_get_port_from_host, def test_delete_host_iface(
self, mock_get_port_from_host,
mock_update_port, mock_port_unbind, mock_conf): mock_update_port, mock_port_unbind, mock_conf):
mock_conf.binding.link_iface = 'eth0' mock_conf.binding.link_iface = 'eth0'
@ -163,7 +166,8 @@ class TestNestedDriver(base.TestKuryrBase):
fake_neutron_port) fake_neutron_port)
mock_get_port_from_host.assert_called_with('eth0') mock_get_port_from_host.assert_called_with('eth0')
mock_update_port.assert_called_with(fake_vm_port['id'], mock_update_port.assert_called_with(
fake_vm_port['id'],
{'port': { {'port': {
'allowed_address_pairs': updated_allowed_pairs 'allowed_address_pairs': updated_allowed_pairs
}}) }})

View File

@ -28,7 +28,8 @@ class TestDriver(base.TestKuryrBase):
@mock.patch.object(driver, '_verify_port_driver_compliancy') @mock.patch.object(driver, '_verify_port_driver_compliancy')
@mock.patch.object(importutils, 'import_object') @mock.patch.object(importutils, 'import_object')
@mock.patch.object(driver, '_parse_port_driver_config') @mock.patch.object(driver, '_parse_port_driver_config')
def test_get_driver_instance(self, mock_parse_config, mock_import_object, def test_get_driver_instance(
self, mock_parse_config, mock_import_object,
mock_verify_compliancy, mock_verify_compatibility): mock_verify_compliancy, mock_verify_compatibility):
module = 'kuryr_libnetwork.port_driver.drivers.veth' module = 'kuryr_libnetwork.port_driver.drivers.veth'
mock_parse_config.return_value = (module, 'veth', 'VethDriver') mock_parse_config.return_value = (module, 'veth', 'VethDriver')

View File

@ -1294,8 +1294,8 @@ class TestKuryr(base.TestKuryrBase):
@mock.patch('kuryr_libnetwork.controllers.app.neutron.list_networks') @mock.patch('kuryr_libnetwork.controllers.app.neutron.list_networks')
@mock.patch('kuryr_libnetwork.controllers.app.neutron.list_subnetpools') @mock.patch('kuryr_libnetwork.controllers.app.neutron.list_subnetpools')
def test_network_driver_create_network_with_network_name_not_exist(self, def test_network_driver_create_network_with_network_name_not_exist(
mock_list_subnetpools, mock_list_networks): self, mock_list_subnetpools, mock_list_networks):
docker_network_id = lib_utils.get_hash() docker_network_id = lib_utils.get_hash()
fake_neutron_network_name = "fake_network" fake_neutron_network_name = "fake_network"
network_request = { network_request = {

View File

@ -887,9 +887,9 @@ class TestKuryrIpam(base.TestKuryrBase):
@mock.patch('kuryr_libnetwork.controllers.app.neutron.list_subnetpools') @mock.patch('kuryr_libnetwork.controllers.app.neutron.list_subnetpools')
@mock.patch('kuryr_libnetwork.controllers.app') @mock.patch('kuryr_libnetwork.controllers.app')
@ddt.data((False), (True)) @ddt.data((False), (True))
def test_ipam_driver_request_address_overlapping_cidr_in_kuryr(self, def test_ipam_driver_request_address_overlapping_cidr_in_kuryr(
use_tag_ext, mock_app, mock_list_subnetpools, mock_list_subnets, self, use_tag_ext, mock_app, mock_list_subnetpools,
mock_create_port, mock_port_add_tag): mock_list_subnets, mock_create_port, mock_port_add_tag):
mock_app.tag_ext = use_tag_ext mock_app.tag_ext = use_tag_ext
# faking list_subnetpools # faking list_subnetpools
fake_kuryr_subnetpool_id = uuidutils.generate_uuid() fake_kuryr_subnetpool_id = uuidutils.generate_uuid()

View File

@ -51,14 +51,8 @@ commands =
commands = python setup.py build_sphinx commands = python setup.py build_sphinx
[flake8] [flake8]
# E125 continuation line does not distinguish itself from next logical line
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent # E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line ignore = E128
# E265 block comment should start with '# '
# N530 direct neutron imports not allowed
# N531 Log messages require translation hints
ignore = E125,E126,E128,E129,E265,H301,N530,N531
show-source = true show-source = true
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes