Enable F841
F841 detects local variable is assigned to but never used. This commit fix the violations and enable F841 in gate. Change-Id: I52419f5e17db70e511ff2d4d61c85458c958e9c3
This commit is contained in:
parent
e6a51f47c4
commit
88d0b6f2d9
@ -215,7 +215,7 @@ class ClientTest(utils.TestCase):
|
||||
fake_client = mock.Mock()
|
||||
mock_http_client.return_value = fake_client
|
||||
with novaclient.v1_1.client.Client("user", "password", "project_id",
|
||||
auth_url="foo/v2") as client:
|
||||
auth_url="foo/v2"):
|
||||
pass
|
||||
self.assertTrue(fake_client.open_session.called)
|
||||
self.assertTrue(fake_client.close_session.called)
|
||||
@ -225,7 +225,7 @@ class ClientTest(utils.TestCase):
|
||||
fake_client = mock.Mock()
|
||||
mock_http_client.return_value = fake_client
|
||||
with novaclient.v3.client.Client("user", "password", "project_id",
|
||||
auth_url="foo/v2") as client:
|
||||
auth_url="foo/v2"):
|
||||
pass
|
||||
self.assertTrue(fake_client.open_session.called)
|
||||
self.assertTrue(fake_client.close_session.called)
|
||||
|
@ -265,7 +265,7 @@ class ShellTest(utils.TestCase):
|
||||
# Ensure that main works with no command-line arguments
|
||||
try:
|
||||
novaclient.shell.main()
|
||||
except SystemExit as exc:
|
||||
except SystemExit:
|
||||
self.fail('Unexpected SystemExit')
|
||||
|
||||
# We expect the normal usage as a result
|
||||
|
@ -32,10 +32,10 @@ cs = fakes.FakeClient(extensions=extensions)
|
||||
class AssistedVolumeSnapshotsTestCase(utils.TestCase):
|
||||
|
||||
def test_create_snap(self):
|
||||
res = cs.assisted_volume_snapshots.create('1', {})
|
||||
cs.assisted_volume_snapshots.create('1', {})
|
||||
cs.assert_called('POST', '/os-assisted-volume-snapshots')
|
||||
|
||||
def test_delete_snap(self):
|
||||
res = cs.assisted_volume_snapshots.delete('x', {})
|
||||
cs.assisted_volume_snapshots.delete('x', {})
|
||||
cs.assert_called('DELETE',
|
||||
'/os-assisted-volume-snapshots/x?delete_info={}')
|
||||
|
@ -33,10 +33,10 @@ class FixedIpsTest(utils.FixturedTestCase):
|
||||
|
||||
def test_reserve_fixed_ip(self):
|
||||
body = {"reserve": None}
|
||||
res = self.cs.fixed_ips.reserve(fixed_ip='192.168.1.1')
|
||||
self.cs.fixed_ips.reserve(fixed_ip='192.168.1.1')
|
||||
self.assert_called('POST', '/os-fixed-ips/192.168.1.1/action', body)
|
||||
|
||||
def test_unreserve_fixed_ip(self):
|
||||
body = {"unreserve": None}
|
||||
res = self.cs.fixed_ips.unreserve(fixed_ip='192.168.1.1')
|
||||
self.cs.fixed_ips.unreserve(fixed_ip='192.168.1.1')
|
||||
self.assert_called('POST', '/os-fixed-ips/192.168.1.1/action', body)
|
||||
|
@ -62,18 +62,18 @@ class HostsTest(utils.TestCase):
|
||||
|
||||
def test_host_startup(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.startup()
|
||||
host.startup()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/startup')
|
||||
|
||||
def test_host_reboot(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.reboot()
|
||||
host.reboot()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/reboot')
|
||||
|
||||
def test_host_shutdown(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.shutdown()
|
||||
host.shutdown()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/shutdown')
|
||||
|
@ -32,7 +32,7 @@ class ImagesTest(utils.TestCase):
|
||||
[self.assertIsInstance(i, images.Image) for i in il]
|
||||
|
||||
def test_list_images_with_limit(self):
|
||||
il = cs.images.list(limit=4)
|
||||
cs.images.list(limit=4)
|
||||
cs.assert_called('GET', '/images/detail?limit=4')
|
||||
|
||||
def test_get_image_details(self):
|
||||
|
@ -222,17 +222,17 @@ class ServersTest(utils.TestCase):
|
||||
cs.assert_called('DELETE', '/servers/1234')
|
||||
|
||||
def test_delete_server_meta(self):
|
||||
s = cs.servers.delete_meta(1234, ['test_key'])
|
||||
cs.servers.delete_meta(1234, ['test_key'])
|
||||
cs.assert_called('DELETE', '/servers/1234/metadata/test_key')
|
||||
|
||||
def test_set_server_meta(self):
|
||||
s = cs.servers.set_meta(1234, {'test_key': 'test_value'})
|
||||
reval = cs.assert_called('POST', '/servers/1234/metadata',
|
||||
cs.servers.set_meta(1234, {'test_key': 'test_value'})
|
||||
cs.assert_called('POST', '/servers/1234/metadata',
|
||||
{'metadata': {'test_key': 'test_value'}})
|
||||
|
||||
def test_set_server_meta_item(self):
|
||||
s = cs.servers.set_meta_item(1234, 'test_key', 'test_value')
|
||||
reval = cs.assert_called('PUT', '/servers/1234/metadata/test_key',
|
||||
cs.servers.set_meta_item(1234, 'test_key', 'test_value')
|
||||
cs.assert_called('PUT', '/servers/1234/metadata/test_key',
|
||||
{'meta': {'test_key': 'test_value'}})
|
||||
|
||||
def test_find(self):
|
||||
|
@ -79,7 +79,7 @@ class ServicesTest(utils.TestCase):
|
||||
self.assertEqual(service.status, 'enabled')
|
||||
|
||||
def test_services_delete(self):
|
||||
service = self.cs.services.delete('1')
|
||||
self.cs.services.delete('1')
|
||||
self.cs.assert_called('DELETE', '/os-services/1')
|
||||
|
||||
def test_services_disable(self):
|
||||
|
@ -66,18 +66,18 @@ class HostsTest(utils.TestCase):
|
||||
|
||||
def test_host_startup(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.startup()
|
||||
host.startup()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/startup')
|
||||
|
||||
def test_host_reboot(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.reboot()
|
||||
host.reboot()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/reboot')
|
||||
|
||||
def test_host_shutdown(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.shutdown()
|
||||
host.shutdown()
|
||||
cs.assert_called(
|
||||
'GET', '/os-hosts/sample_host/shutdown')
|
||||
|
@ -36,7 +36,7 @@ class ImagesTest(utils.TestCase):
|
||||
self.assertIsInstance(i, images.Image)
|
||||
|
||||
def test_list_images_with_limit(self):
|
||||
il = cs.images.list(limit=4)
|
||||
cs.images.list(limit=4)
|
||||
cs.assert_called('GET', '/v1/images/detail?limit=4')
|
||||
|
||||
def test_get_image_details(self):
|
||||
|
@ -212,12 +212,12 @@ class ServersTest(utils.TestCase):
|
||||
cs.assert_called('DELETE', '/servers/1234')
|
||||
|
||||
def test_delete_server_meta(self):
|
||||
s = cs.servers.delete_meta(1234, ['test_key'])
|
||||
cs.servers.delete_meta(1234, ['test_key'])
|
||||
cs.assert_called('DELETE', '/servers/1234/metadata/test_key')
|
||||
|
||||
def test_set_server_meta(self):
|
||||
s = cs.servers.set_meta(1234, {'test_key': 'test_value'})
|
||||
reval = cs.assert_called('POST', '/servers/1234/metadata',
|
||||
cs.servers.set_meta(1234, {'test_key': 'test_value'})
|
||||
cs.assert_called('POST', '/servers/1234/metadata',
|
||||
{'metadata': {'test_key': 'test_value'}})
|
||||
|
||||
def test_find(self):
|
||||
|
@ -26,7 +26,7 @@ class VolumesTest(utils.TestCase):
|
||||
return fakes.FakeClient()
|
||||
|
||||
def test_attach_server_volume(self):
|
||||
v = self.cs.volumes.attach_server_volume(
|
||||
self.cs.volumes.attach_server_volume(
|
||||
server=1234,
|
||||
volume_id='15e59938-07d5-11e1-90e3-e3dffe0c5983',
|
||||
device='/dev/vdb'
|
||||
@ -35,7 +35,7 @@ class VolumesTest(utils.TestCase):
|
||||
|
||||
def test_update_server_volume(self):
|
||||
vol_id = '15e59938-07d5-11e1-90e3-e3dffe0c5983'
|
||||
v = self.cs.volumes.update_server_volume(
|
||||
self.cs.volumes.update_server_volume(
|
||||
server=1234,
|
||||
old_volume_id='Work',
|
||||
new_volume_id=vol_id
|
||||
|
@ -351,7 +351,7 @@ def _load_entry_point(ep_name, name=None):
|
||||
def is_integer_like(val):
|
||||
"""Returns validation of a value as an integer."""
|
||||
try:
|
||||
value = int(val)
|
||||
int(val)
|
||||
return True
|
||||
except (TypeError, ValueError, AttributeError):
|
||||
return False
|
||||
|
@ -1437,9 +1437,8 @@ def do_volume_attach(cs, args):
|
||||
if args.device == 'auto':
|
||||
args.device = None
|
||||
|
||||
volume = cs.volumes.attach_server_volume(_find_server(cs, args.server).id,
|
||||
args.volume,
|
||||
args.device)
|
||||
cs.volumes.attach_server_volume(_find_server(cs, args.server).id,
|
||||
args.volume, args.device)
|
||||
|
||||
|
||||
@utils.arg('server',
|
||||
@ -1453,9 +1452,8 @@ def do_volume_attach(cs, args):
|
||||
help='ID of the volume to attach.')
|
||||
def do_volume_update(cs, args):
|
||||
"""Update volume attachment."""
|
||||
volume = cs.volumes.update_server_volume(_find_server(cs, args.server).id,
|
||||
args.attachment_id,
|
||||
args.new_volume)
|
||||
cs.volumes.update_server_volume(_find_server(cs, args.server).id,
|
||||
args.attachment_id, args.new_volume)
|
||||
|
||||
|
||||
@utils.arg('server',
|
||||
|
2
tox.ini
2
tox.ini
@ -28,6 +28,6 @@ downloadcache = ~/cache/pip
|
||||
[flake8]
|
||||
# TODO fix following rules from hacking 0.9
|
||||
# E131,E265,H233,H305,H307,H402,H405,H904
|
||||
ignore = E12,E131,E265,F841,F811,F821,H233,H302,H305,H307,H402,H404,H405,H904
|
||||
ignore = E12,E131,E265,F811,F821,H233,H302,H305,H307,H402,H404,H405,H904
|
||||
show-source = True
|
||||
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build
|
||||
|
Loading…
Reference in New Issue
Block a user