Fix pep8
This patch fixes the issues that pep8 is showing in our CI. Flake8 changes in tox.ini: -Added ironic/tests/base.py and ironic/cmd/__init__.py to per-file-ignores to ignore E402. -Added E741 to ignore. Change-Id: Icf92aa186fb4b2be0d59736a56260d01a5c3279a
This commit is contained in:
parent
855986c024
commit
ead9ecfcbc
@ -19,7 +19,7 @@
|
||||
# concurrency models can cause undefined behavior and potentially API timeouts.
|
||||
import os
|
||||
|
||||
os.environ['EVENTLET_NO_GREENDNS'] = 'yes' # noqa E402
|
||||
os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
|
||||
|
||||
import eventlet
|
||||
|
||||
@ -27,10 +27,11 @@ eventlet.monkey_patch(os=False)
|
||||
# Monkey patch the original current_thread to use the up-to-date _active
|
||||
# global variable. See https://bugs.launchpad.net/bugs/1863021 and
|
||||
# https://github.com/eventlet/eventlet/issues/592
|
||||
# all the noqa below are for I202 due to 'import eventlet' above
|
||||
import __original_module_threading as orig_threading # noqa
|
||||
import threading # noqa
|
||||
orig_threading.current_thread.__globals__['_active'] = threading._active
|
||||
|
||||
from ironic.common import i18n # noqa for I202 due to 'import eventlet' above
|
||||
from ironic.common import i18n # noqa
|
||||
|
||||
i18n.install('ironic')
|
||||
|
@ -480,7 +480,7 @@ def dhcp_options_for_instance(task, ipxe_enabled=False, url_boot=False,
|
||||
LOG.warning('IPv6 is enabled and the DHCP driver appears set '
|
||||
'to a plugin aside from "neutron". Node %(name)s '
|
||||
'may not receive proper DHCPv6 provided '
|
||||
'boot parameters.'.format(name=task.node.uuid))
|
||||
'boot parameters.', {'name': task.node.uuid})
|
||||
# NOTE(TheJulia): This was added for ISC DHCPd support, however it
|
||||
# appears that isc support was never added to neutron and is likely
|
||||
# a down stream driver.
|
||||
|
@ -28,7 +28,7 @@ import sys
|
||||
import tempfile
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch(os=False) # noqa E402
|
||||
eventlet.monkey_patch(os=False)
|
||||
import fixtures
|
||||
from ironic_lib import utils
|
||||
from oslo_concurrency import processutils
|
||||
|
@ -185,9 +185,9 @@ class TestListAllocations(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=self.headers))
|
||||
|
||||
def test_collection_links(self):
|
||||
|
@ -190,9 +190,10 @@ class TestListChassis(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'],
|
||||
bookmark=bookmark))
|
||||
|
||||
if public_url is not None:
|
||||
expected = [{'href': '%s/v1/chassis/%s' % (public_url, uuid),
|
||||
|
@ -156,9 +156,9 @@ class TestListConductors(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn('rocky.rocks', data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=headers))
|
||||
|
||||
if public_url is not None:
|
||||
|
@ -216,9 +216,9 @@ class TestListDeployTemplates(BaseDeployTemplatesAPITest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=self.headers))
|
||||
|
||||
def test_collection_links(self):
|
||||
|
@ -270,9 +270,10 @@ class TestListDrivers(base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(self.hw1, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'],
|
||||
bookmark=bookmark))
|
||||
|
||||
if public_url is not None:
|
||||
expected = [{'href': '%s/v1/drivers/%s' % (public_url, self.hw1),
|
||||
|
@ -1103,9 +1103,10 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'],
|
||||
bookmark=bookmark))
|
||||
|
||||
if public_url is not None:
|
||||
expected = [{'href': '%s/v1/nodes/%s' % (public_url, uuid),
|
||||
|
@ -664,9 +664,10 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark))
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'],
|
||||
bookmark=bookmark))
|
||||
|
||||
if public_url is not None:
|
||||
expected = [{'href': '%s/v1/ports/%s' % (public_url, uuid),
|
||||
|
@ -288,9 +288,9 @@ class TestListPortgroups(test_api_base.BaseApiTest):
|
||||
self.assertIn('ports', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=self.headers))
|
||||
|
||||
def test_collection_links(self):
|
||||
|
@ -25,9 +25,9 @@ class TestGetVolume(test_api_base.BaseApiTest):
|
||||
def _test_links(self, data, key, headers):
|
||||
self.assertIn(key, data)
|
||||
self.assertEqual(2, len(data[key]))
|
||||
for l in data[key]:
|
||||
bookmark = (l['rel'] == 'bookmark')
|
||||
self.assertTrue(self.validate_link(l['href'],
|
||||
for link in data[key]:
|
||||
bookmark = (link['rel'] == 'bookmark')
|
||||
self.assertTrue(self.validate_link(link['href'],
|
||||
bookmark=bookmark,
|
||||
headers=headers))
|
||||
|
||||
|
@ -233,9 +233,9 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=self.headers))
|
||||
|
||||
def test_collection_links(self):
|
||||
|
@ -223,9 +223,9 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
bookmark = l['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(l['href'], bookmark=bookmark,
|
||||
for link in data['links']:
|
||||
bookmark = link['rel'] == 'bookmark'
|
||||
self.assertTrue(self.validate_link(link['href'], bookmark=bookmark,
|
||||
headers=self.headers))
|
||||
|
||||
def test_collection_links(self):
|
||||
|
@ -29,10 +29,7 @@ class BlockExecuteTestCase(base.TestCase):
|
||||
subprocess.check_output, utils.execute)
|
||||
|
||||
for function_name in execute_functions:
|
||||
exc = self.assertRaises(
|
||||
Exception,
|
||||
function_name,
|
||||
["echo", "%s" % function_name]) # noqa
|
||||
exc = self.assertRaises(Exception, function_name, ["echo", "%s" % function_name]) # noqa
|
||||
# Have to use 'noqa' as we are raising plain Exception and we will
|
||||
# get H202 error in 'pep8' check.
|
||||
|
||||
@ -58,10 +55,7 @@ class BlockExecuteTestCase(base.TestCase):
|
||||
# still get an exception for a child. So in this case
|
||||
# ironic_lib.utils.execute() calls processutils.execute(). Make sure an
|
||||
# exception is raised even though we mocked processutils.execute()
|
||||
exc = self.assertRaises(
|
||||
Exception,
|
||||
utils.execute,
|
||||
"ls") # noqa
|
||||
exc = self.assertRaises(Exception, utils.execute, "ls") # noqa
|
||||
# Have to use 'noqa' as we are raising plain Exception and we will get
|
||||
# H202 error in 'pep8' check.
|
||||
|
||||
|
7
tox.ini
7
tox.ini
@ -109,8 +109,10 @@ deps =
|
||||
commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
# [E129] visually indented line with same indent as next logical line
|
||||
# [E741] ambiguous variable name
|
||||
# [W503] Line break before binary operator.
|
||||
ignore = E129,W503
|
||||
ignore = E129,E741,W503
|
||||
filename = *.py,app.wsgi
|
||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
import-order-style = pep8
|
||||
@ -126,6 +128,8 @@ enable-extensions=H106,H203,H204,H205,H210,H904
|
||||
# TODO(rpittau) remove the ignores below when we're ready to apply H210 to
|
||||
# the various modules. This can be done in batches changing the filters.
|
||||
per-file-ignores =
|
||||
ironic/cmd/__init__.py:E402
|
||||
ironic/tests/base.py:E402
|
||||
ironic/tests/unit/api/*:H210
|
||||
ironic/tests/unit/conductor/*:H210
|
||||
ironic/tests/unit/common/*:H210
|
||||
@ -163,4 +167,3 @@ deps =
|
||||
[testenv:bandit]
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = bandit -r ironic -x tests -n5 -ll -c tools/bandit.yml
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user