From 036703c8d4ae66595cbbbfc17b1afe8c0c46a7b2 Mon Sep 17 00:00:00 2001 From: jacky06 Date: Fri, 15 May 2020 01:23:50 +0800 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Change-Id: I71b869fc509cb46b55b1e88fae20422bcba085f7 --- kuryr_libnetwork/controllers.py | 6 +++--- kuryr_libnetwork/port_driver/drivers/sriov.py | 2 +- kuryr_libnetwork/tests/unit/base.py | 1 - .../tests/unit/port_driver/test_driver.py | 13 +++++++------ lower-constraints.txt | 3 --- test-requirements.txt | 2 +- tox.ini | 3 ++- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/kuryr_libnetwork/controllers.py b/kuryr_libnetwork/controllers.py index dbf11414..be78be9c 100644 --- a/kuryr_libnetwork/controllers.py +++ b/kuryr_libnetwork/controllers.py @@ -1044,7 +1044,7 @@ def network_driver_delete_network(): subnet_name = subnet.get('name') if str(subnet_name).startswith(const.SUBNET_NAME_PREFIX): app.neutron.delete_subnet(subnet['id']) - except n_exceptions.Conflict as ex: + except n_exceptions.Conflict: LOG.error("Subnet %s is in use, " "can't be deleted.", subnet['id']) except n_exceptions.NeutronClientException as ex: @@ -1086,7 +1086,7 @@ def network_driver_delete_network(): # and it's totally the normal case. So we'd just log that # and continue to proceed. app.neutron.delete_subnet(subnet['id']) - except n_exceptions.Conflict as ex: + except n_exceptions.Conflict: LOG.error("Subnet, %s, is in use. Network can't " "be deleted.", subnet['id']) raise @@ -1856,7 +1856,7 @@ def ipam_release_pool(): try: app.neutron.delete_subnetpool(pool_id) - except n_exceptions.Conflict as ex: + except n_exceptions.Conflict: LOG.info("The subnetpool with ID %s is still in use." " It can't be deleted for now.", pool_id) except n_exceptions.NeutronClientException as ex: diff --git a/kuryr_libnetwork/port_driver/drivers/sriov.py b/kuryr_libnetwork/port_driver/drivers/sriov.py index 1ca4210c..3ef8d2e5 100644 --- a/kuryr_libnetwork/port_driver/drivers/sriov.py +++ b/kuryr_libnetwork/port_driver/drivers/sriov.py @@ -52,7 +52,7 @@ def get_vf_num_by_pci_address(pci_addr): A VF is associated with an VF number, which ip link command uses to configure it. This number can be obtained from the PCI device filesystem. """ - VIRTFN_RE = re.compile("virtfn(\d+)") + VIRTFN_RE = re.compile(r"virtfn(\d+)") virtfns_path = "/sys/bus/pci/devices/%s/physfn/virtfn*" % (pci_addr) vf_num = None try: diff --git a/kuryr_libnetwork/tests/unit/base.py b/kuryr_libnetwork/tests/unit/base.py index fdd68df0..2d2b1494 100644 --- a/kuryr_libnetwork/tests/unit/base.py +++ b/kuryr_libnetwork/tests/unit/base.py @@ -363,7 +363,6 @@ class TestKuryrBase(TestCase): }], "id": "65c0ee9f-d634-4522-8954-51021b570b0d", "security_groups": [], - "device_id": "" } } return fake_port diff --git a/kuryr_libnetwork/tests/unit/port_driver/test_driver.py b/kuryr_libnetwork/tests/unit/port_driver/test_driver.py index 24eecee8..2f664b28 100644 --- a/kuryr_libnetwork/tests/unit/port_driver/test_driver.py +++ b/kuryr_libnetwork/tests/unit/port_driver/test_driver.py @@ -106,8 +106,8 @@ class TestNestedDriverFailures(base.TestKuryrFailures): @mock.patch('kuryr_libnetwork.config.CONF') def test__verify_binding_driver_compatibility_not_compatible(self, m_conf): m_conf.binding.enabled_drivers = ['macvlan'] - message = "Configuration file error: port driver 'veth' is not " \ - "compatible with binding driver '\['macvlan'\]'" + message = r"Configuration file error: port driver 'veth' is not " \ + r"compatible with binding driver '\['macvlan'\]'" fake_driver = mock.Mock(spec=driver.Driver) fake_driver.get_supported_bindings.return_value = ('veth',) @@ -118,8 +118,8 @@ class TestNestedDriverFailures(base.TestKuryrFailures): def test__verify_binding_driver_compatibility_not_compatible_multi_drivers( self, m_conf): m_conf.binding.enabled_drivers = ['macvlan', 'sriov'] - message = "Configuration file error: port driver 'veth' is not " \ - "compatible with binding driver '\['macvlan'\, 'sriov']'" + message = r"Configuration file error: port driver 'veth' is not " \ + r"compatible with binding driver '\['macvlan'\, 'sriov']'" fake_driver = mock.Mock(spec=driver.Driver) fake_driver.get_supported_bindings.return_value = ('veth',) @@ -129,8 +129,9 @@ class TestNestedDriverFailures(base.TestKuryrFailures): @mock.patch('kuryr_libnetwork.config.CONF') def test__verify_binding_driver_compatibility_not_supported(self, m_conf): m_conf.binding.enabled_drivers = ['ipvlan'] - message = "Configuration file error: binding driver '\['ipvlan'\]' is " \ - "currently not supported with 'nested' port driver" + message = r"Configuration file error: binding driver " \ + r"'\['ipvlan'\]' is currently not supported " \ + r"with 'nested' port driver" fake_driver = mock.Mock(spec=driver.Driver) fake_driver.get_supported_bindings.return_value = ('ipvlan',) diff --git a/lower-constraints.txt b/lower-constraints.txt index 3dc3ca16..b5b249ac 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -25,12 +25,10 @@ eventlet==0.20.0 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 Flask==0.10 future==0.16.0 futurist==1.6.0 greenlet==0.4.13 -hacking==0.12.0 idna==2.6 imagesize==1.0.0 iso8601==0.1.12 @@ -82,7 +80,6 @@ pep8==1.5.7 pika==0.10.0 pika-pool==0.1.3 prettytable==0.7.2 -pyflakes==0.8.1 Pygments==2.2.0 pyinotify==0.9.6 pyparsing==2.2.0 diff --git a/test-requirements.txt b/test-requirements.txt index 05ca1854..2f2c3e74 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,11 +2,11 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. +hacking>=3.0.1,<3.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 ddt>=1.0.1 # MIT docker>=2.4.2 # Apache-2.0 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 stestr>=1.0.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 openstackdocstheme>=1.18.1 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 32907c4c..7eabc39a 100644 --- a/tox.ini +++ b/tox.ini @@ -55,7 +55,8 @@ commands = [flake8] # E128 continuation line under-indented for visual indent -ignore = E128 +# W504 line break after binary operator +ignore = E128,W504 show-source = true exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes